다형성 쿼리
TYPE
조회 대상을 특정 자식으로 한정 ex) Item 중에 Book, Movie를 조회할 때
JPQL
select i from Item i
where type(i) IN (Book, Movie)
SQL
select i from i
where i.DTYPE in (‘B’, ‘M’)
TREAT
자바의 타입 캐스팅과 유사
상속 구조에서 부모 타입을 특정 자식 타입으로 다룰 때 사용 =>부모 클래스를 자식 클래스로 다운캐스팅 가능!
FROM, WHERE, SELECT(하이버네이트 지원) 사용
JPQL
select i from Item i
where treat(i as Book).auther = 'kim'
SQL
select i.* from Item i
where i.DTYPE = 'B' and i.auther = 'kim'
Last updated
Was this helpful?