728x90
spring data jpa 메소드 이름으로 쿼리 생성
http://docs.spring.io/spring-data/jpa/docs/1.4.1.RELEASE/reference/html/jpa.repositories.html
word | 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 |
IsNotNull,NotNull | findByAge(Is)NotNull | … where x.age not null |
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 % ) |
Containing | findByFirstnameContaining | … where x.firstname like ?1 (parameter bound wrapped in % ) |
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 |
빠진 것
lessThenEqual <=
greaterThanEqual >=
JpaRepository interface에 생성해준다.
List<LiveBaseGame> findByGdateAndGtimeBetweenAndGtype(String gdate, String departureGtime, String arrivalGtime, String gtype);
end.
728x90
'Spring > Spring Data JPA' 카테고리의 다른 글
@DiscriminatorColumn을 이용한 Spring Data Jpa 상속관계(Inheritance) 매핑 하기 (2) | 2017.06.22 |
---|---|
Spring Data Jpa로 Restful API구축 할 때 날짜 출력 설정 (0) | 2017.06.02 |
그래들(gradle)로 스프링 부트 JPA 빌드하고 DB연동 하는 예제 (2) | 2017.05.09 |
Spring Data JPA 날짜 between (4) | 2017.04.27 |
Spring Data Jpa Native Query 사용법 (0) | 2017.04.04 |
spring data jpa 메소드 이름으로 쿼리 생성 (0) | 2017.02.24 |