JPA | JpaRepository
JpaRepository
JpaRepository는 인터페이스이다.
인터페이스란 미리정의되어 있는 메소드를 호출만으로 사용이 가능하다
jpql 라는 쿼리문을 사용하기 위한용도이다
@Repository
public interface SampleEntityRepository extends JpaRepository <SampleEntity, Long> {
}
아래와 같이
extends키워드를 가지고 사용을 한다 제레믹<>안에는 엔티티와 , pk 타입을 지정해 주면 된다.
public interface DoaminRepository extends JpaRepository <엔티티,ID 유형>
JPA 키워드
| 키워드 | 예제 | 설명 |
|---|---|---|
| And | findByNameAndContent | Where name = ? and content = ? |
| or | findByNameNameOrContent | Where name = ? or content = ? |
| Is , Equals | findByNameIs | |
| findByNameEquals | where name = ? | |
| Between | findByStartDateBetween | Where startDate between ? and ? |
| LessThan | findByNumLessThan | where num < ? |
| LessThanEqual | findByNumLessThan | where num <= ? |
| GreaterThan | findByNumGreaterThan | where num > ? |
| GreaterThanEqual | findByNumGreaterThanEqual | where num >= ? |
| After | findByStartDateAfter | where startDate > ? |
| Before | findByStartDateBefore | where startDate < ? |
| IsNull Null | findByNum(Is)Null | where num is null |
| isNotNull NotNull | findByNum(Is)NotNull | Where num not null |
| Like | findByNameLike | where name like ? |
| NotLike | findByNameNotLike | where name not like ? |
| StartingWith | findByNameStartingWith | where name like '%?' |
| EndingWith | findByNameEndingWith | where name like '?%' |
| Containing | findByNameContaining | where Name like '%?%' |
| OrderBy | findByNumOrderByName | where num = ? order by name desc |
| Not | findByNameNot | where name <> ? |
| In | findByNameIn | where name in ? |
| NotIn | findByNameNotIn | where name not in ? |
| True | findByActiveTrue | where active = true |
| False | findByActiveFalse | where active = false |
| IgnoreCase | findByNameIgnoreCase | where upper(name) = upper(?) |
Author And Source
이 문제에 관하여(JPA | JpaRepository), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@ewan/What-is-JPA-JpaRepository-편저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)