我有两个 JPA 实体,例如:
public class Request{
@OneToOne
private User user;
private Date submitted;
@OneToOne(cascade=CascadeType.ALL, mappedBy="id.request", optional=true, fetch=FetchType.EAGER)
private Appointment;
}
public class Appointment{
@EmbeddedId
private AppointmentId id;
public static class AppointmentPk{
@OneToOne
private Request request;
private LocalDate date;
}
}
然后我进行 JPQL 查询(使用spring data):
SELECT r.appointment, r FROM Request r INNER JOIN FETCH r.appointment a
我有一个数组列表作为结果 valorized 为:
- array[0]: 正确的约会
appointment
array[1]: 带有属性的请求null
似乎不可能在从查询appointment
中检索到的属性中获得价值Request
……我想念什么?