mybatis jpa repository 方法关键词对应关系表

注意:jpa的sql是面向对象的,因此from后的表名可以使用相应的实体类,占位符用?1代表参数里的第几个参数,相当于mybatis参数中的@param。

Keyword Sample JPQL snippet IsNotNull findByAgeNotNull … where x.age not null Like findByNameLike … where x.name like ?1 NotLike findByNameNotLike … where x.name not like ?1 StartingWith findByNameStartingWith … where x.name like ?1(parameter bound with appended %) EndingWith findByNameEndingWith … where x.name like ?1(parameter bound with prepended %) Containing findByNameContaining … where x.name like ?1(parameter bound wrapped in %) OrderBy findByAgeOrderByName … where x.age = ?1 order by x.name desc Not findByNameNot … where x.name <> ?1 In findByAgeIn … where x.age in ?1 NotIn findByAgeNotIn … where x.age not in ?1 True findByActiveTrue … where x.avtive = true Flase findByActiveFalse … where x.active = false And findByNameAndAge … where x.name = ?1 and x.age = ?2 Or findByNameOrAge … where x.name = ?1 or x.age = ?2 Between findBtAgeBetween … where x.age between ?1 and ?2 LessThan findByAgeLessThan … where x.age < ?1 GreaterThan findByAgeGreaterThan … where x.age > ?1 After/Before … … IsNull findByAgeIsNull … where x.age is null
经验分享 程序员 微信小程序 职场和发展