0
이 쿼리를 jpa로 변환하려고합니다. 내 SQL 원시 쿼리.JPA 쿼리를 사용하지 않고
SELECT *
FROM tripinfo ti
inner join car c on ti.carid = c.id
left join customerdetail cd on ti.customerid = cd.id
left join station s on ti.fromstxid = s.id
where ti.starttime is null or ti.stoptime is null
내 JPA 쿼리 명령에
SELECT ti
FROM TripInfo ti
join ti.car
left join CustomerDetail cd on ti.customer.customerDetail.id = cd.id
left join Station st on ti.fromstxid = st.id
는 JPA 2.0에 존재하지 않는 것.
TripInfo 클래스
public class tripInfo{
Long id
@OneToOne
JoinColumn(name = "customerId") //can be null
Customer customer;
@OneToOne
@JoinColumn(name = "carid")
Car car;
@Column(name = "tostxid") //can be null
Long toStxId;
@Column(name = "fromstxid") //can be null
Long fromStxId;
@OneToOne(cascade = { CascadeType.ALL })
@JoinColumn(name = "fromdp")
DP fromDP;
}
고객 클래스
public class Customer {
Long id
@OneToOne(cascade = { CascadeType.ALL })
@JoinColumn(name = "customerDetail_customerid")
CustomerDetail customerDetail;
}
DP 클래스
public class DP {
@OneToOne(cascade = { CascadeType.ALL })
@JoinColumn(name = "stationFrom")
Station stationFrom;
}
명령에를 우회하는 어떤 생각?
제가 가 ti.car 시정 ti.customer.customerDetail가 CD를 가입 왼쪽 가입하기 TripInfo 된 TI의 다른 클래스 – redfox26
SELECT TI 통과 기준 추가 ti.fromDP.stationFrom 세인트 가입 왼쪽 – Gayathri