關鍵字 | 方法命名 | sql where字句 |
And | findByNameAndPwd | where name= ? and pwd =? |
Or | findByNameOrSex | where name= ? or sex=? |
Is,Equals | findById,findByIdEquals | where id= ? |
Between | findByIdBetween | where id between ? and ? |
LessThan | findByIdLessThan | where id < ? |
LessThanEquals | findByIdLessThanEquals | where id <= ? |
GreaterThan | findByIdGreaterThan | where id > ? |
GreaterThanEqual | findByAgeGreaterThanEqual | where age >= ? |
After | findByIdAfter | where id > ? |
Before | findByIdBefore | where id < ? |
IsNull | findByNameIsNull | where name is null |
isNotNull,NotNull | findByNameNotNull | where name is not null |
Like | findByNameLike | where name like ? |
NotLike | findByNameNotLike | where name not like ? |
StartingWith |
findByNameStartingWith | where name like '?%' |
EndingWith | findByNameEndingWith | where name like '%?' |
Containing | findByNameContaining | where name like '%?%' |
OrderBy | findByIdOrderByXDesc | where id=? order by x desc |
Not | findByNameNot | where name <> ? |
In | findByIdIn(Collection<?> c) | where id in (?) |
NotIn | findByIdNotIn(Collection<?> c) | where id not in (?) |
True |
findByAaaTue |
where aaa = true |
False | findByAaaFalse | where aaa = false |
IgnoreCase | findByNameIgnoreCase | where UPPER(name)=UPPER(?) |
top | findTop100 | top 10/where ROWNUM <=10 |
示例:
// demo /** * 根據comId 和 state 查詢從導入初始值開始到生效時間最新的記錄 * <p> * 2017年7月13日 13:37:49 * xj * * @param comId 公司代碼 * @param state 狀態爲1 爲刪除的狀態 * @param effectTimeStart 固定值 1970-01-01 * @param effectTime 生效時間 * @return */ List<CompanyIndustry> findTop1ByComIdAndStateAndEffectTimeBetweenOrderByEffectTimeDesc(String comId, Integer state, Date effectTimeStart, Date effectTime);
轉載於:http://blog.csdn.net/sbin456/article/details/53304148 綜合跟新了下