Spring Data JPA进阶
2018-09-27 本文已影响0人
红紫黑白灰
创建数据,添加查询功能
- JPA中支持的关键词
And:findByUsernameAndPassword(String user, Striang pwd);
Or :findByUsernameOrAddress(String user, String addr);
Between : findBySalaryBetween(int max, int min);
LessThan:findBySalaryLessThan(int max);
GreaterThan :findBySalaryGreaterThan(int min);
IsNull:findByUsernameIsNull();
IsNotNull :findByUsernameIsNotNull();
NotNull :与 IsNotNull 等价;
Like:findByUsernameLike(String user);
NotLike :findByUsernameNotLike(String user);
OrderBy :findByUsernameOrderBySalaryAsc(String user);
Not:findByUsernameNot(String user);
In :findByUsernameIn(Collection<String> userList) ,方法的参数可以是 Collection 类型,也可以是数组或者不定长参数;
NotIn :findByUsernameNotIn(Collection<String> userList) ,方法的参数可以是 Collection 类型,也可以是数组或者不定长参数;
实例类型
https://github.com/heiyeziran/JPA/commit/eec9b69626d05889c9cbf6bad3af1226502ebb28