Table 4.
Supported keywords inside method names
Keyword Sample JPQL snippet
Java Persistence Query Language
And findByLastnameAndFirstname … wherex.lastname = ?1 and x.firstname = ?2
Or findByLastnameOrFirstname … wherex.lastname = ?1 or x.firstname = ?2
Is,Equals findByFirstname,findByFirstnameIs,findByFirstnameEquals … wherex.firstname = ?1
Between findByStartDateBetween … wherex.startDate between ?1 and ?2
LessThan findByAgeLessThan … wherex.age < ?1
LessThanEqual findByAgeLessThanEqual … wherex.age <= ?1
GreaterThan findByAgeGreaterThan … wherex.age > ?1
GreaterThanEqual findByAgeGreaterThanEqual … wherex.age >= ?1
After findByStartDateAfter … wherex.startDate > ?1
Before findByStartDateBefore … wherex.startDate < ?1
IsNull findByAgeIsNull … wherex.age is null
IsNotNull,NotNull findByAge(Is)NotNull … wherex.age not null
Like findByFirstnameLike … wherex.firstname like ?1
NotLike findByFirstnameNotLike … wherex.firstname not like ?1
StartingWith findByFirstnameStartingWith … wherex.firstname like ?1 (parameter bound with
appended %) where x.firstname like ‘?%’
EndingWith findByFirstnameEndingWith … where x.firstname like ?1 (parameter bound with
prepended %) where x.firstname like ‘%?’
Containing findByFirstnameContaining … where x.firstname like ?1 (parameter bound
wrapped in %) where x.firstname like ‘%?%’
OrderBy findByAgeOrderByLastnameDesc … where x.age = ?1 order by x.lastname desc
Not findByLastnameNot … where x.lastname <> ?1
In findByAgeIn(Collection<Age> ages) … where x.age in ?1
NotIn findByAgeNotIn(Collection<Age> age) … where x.age not in ?1
True findByActiveTrue() … where x.active = true
False findByActiveFalse() … where x.active = false
IgnoreCase findByFirstnameIgnoreCase … where UPPER(x.firstame) = UPPER(?1)
First findFirstBy … limit 1
Top findTopBy … limit 1
First findFirst15By … limit 15
Top findTop15By … limit 15
Top findTop20ByOrderByAgeDesc … order by x.age desc limit 20
https://docs.spring.io/spring-data/jpa/docs/2.0.0.RC2/reference/html/#jpa.query-methods