0
우리는 jpa/hibernate를 사용하지만이 쿼리와 같은 네이티브 쿼리가 있습니다.중첩 된 sql 쿼리를 jpa/hibernate로 변환
SELECT cp1.id AS customerbookid
FROM customerbook cp1
INNER JOIN customer cu ON cu.id = cp1.customerid
WHERE cp1.autoRenew='Y'
AND cp1.endTime < now()
AND
(SELECT cp2.customerid
FROM customerbook cp2
WHERE cp1.customerid=cp2.customerid
AND cp2.startTime > now()
) IS NULL
매핑
@Entity
@Table(name = "customerbook")
public class CustomerBook{
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "customerId")
private long customerId;
@Column(name = "startTime")
private Timestamp startTime;
@Column(name = "endTime")
private Timestamp endTime;
@Column(name = "autoRenew")
private Character autoRenew;
}
@Entity
@Table(name = "customer")
public class customer{
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
}
그것은 JPA로 변환 할 수 있습니까?
JPQL을 의미합니까? –
예 JPQL. 우리는 jpa로 hql을 사용할 수 있습니까? – redfox26
'JPA'는'API'입니다. 'Hibernate'는 JPA ** 구현 중 하나입니다 **. 'HQL'은 Hibernate 특정 언어입니다. –