Databases Reference
In-Depth Information
Keywords
Keywords are used to specify constraints against the values of properties referred
by property expressions. There are two rules that are used to combine property
expressions together with keywords:
• We can create a constraint by adding a keyword after a property expression
• We can combine constraints by adding either the And or Or keyword
between them
The reference manual of Spring Data JPA ( http://static.springsource.org/
spring-data/data-jpa/docs/current/reference/html/ ) describes how property
expressions and keywords can be used for creating query methods:
Keyword
Sample
JPQL Snippet
And
findByLastNameAndFirstName
where x.lastname =
?1 and x.firstname
= ?2
Or
findByLastNameOrFirstName
where x.lastname =
?1 or x.firstname =
?2
Between
findByStartDateBetween
where x.startDate
between 1? and ?2
LessThan
findByAgeLessThan
where x.age < ?1
GreaterThan
findByAgeGreaterThan
where x.age > ?1
After
findByStartDateAfter
where x.startDate >
?1
Before
findByStartDateBefore
where x.startDate <
?1
IsNull
findByAgeIsNull
where x.age is null
where x.age is not
null
IsNotNull ,
NotNull
findByAge ( Is ) NotNull
Like
findByFirstNameLike
where x.firstname
like ?1
NotLike
findByFirstNameNotLike
where x.firstname
not like ?1
StartingWith
findByFirstNameStartingWith
where x.firstname
like ?1 (parameter
bound with appended % )
EndingWith
findByFirstNameEndingWith
where x.firstname
like ?1 (parameter
bound with prepended % )
Search WWH ::




Custom Search