我有以下表格,具有指定的关系:
使用以下型号:
...
@AssociationOverrides({
@AssociationOverride(name = "primaryKey.userId",
joinColumns = @JoinColumn(name = "`userId`")),
@AssociationOverride(name = "primaryKey.citaId",
joinColumns = @JoinColumn(name = "`citaId`")) })
public class UsuarioCita {
private UsuarioCitaPK primaryKey = new UsuarioCitaPK();
...
复合键:
@Embeddable
public class UsuarioCitaPK implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private User userId;
private Cita citaId;
@ManyToOne(cascade=CascadeType.PERSIST)
public User getUserId() {
return userId;
}
public void setUserId(User userId) {
this.userId = userId;
}
@ManyToOne(cascade=CascadeType.PERSIST)
public Cita getCitaId() {
return citaId;
}
在Cita模型中:
@OneToMany(mappedBy="primaryKey.citaId", cascade=CascadeType.PERSIST)
private List<UsuarioCita> usuarioCita;
如何在这两个表之间用JPQL编写连接查询?由于UsuarioCita使用复合键。