JDBC, Transactions, Spring Data JPA
July 31, 2021
M03 Q27 What is the naming convention for finder methods in a Repository interface?
limit – result of the query can be limited by usage of first/top keyword
findFirst10ByLastnamefindFirstByOrderByLastnameAscfindTop3ByLastnamefindTopByOrderByAgeDesc
property/properties expression – result will be filtered based on property of entity, multiple properties can be used with usage of And, Or keyword
findByLastnameAndFirstnamefindByLastnameOrFirstnamefindByFirstname
comparison – comparison mode can be specified after specifying property used for filtering
findByFirstnameIsfindByFirstnameEqualsfindByStartDateBetweenfindByAgeLessThan,findByAgeLessThanEqualfindByAgeGreaterThan,findByAgeGreaterThanEqualfindByStartDateBefore,findByStartDateAfterfindByAgeIsNull,findByAgeIsNotNullfindByFirstnameLike,findByFirstnameNotLikefindByFirstnameStartingWith,findByFirstnameEndingWithfindByFirstnameContainingfindByLastnameNotfindByAgeIn(Collection ages),findByAgeNotIn(Collection ages)findByActiveTrue,findByActiveFalsefindByFirstnameIgnoreCase
ordering operator – optionally you can specify ordering operator at the end of method name
findByLastnameOrderByFirstnameAscfindByLastnameOrderByFirstnameDesc