我有这个实体。
@Entity
@Table(name ="ESCALADETALHE")
public class EscalaDiaBean {
@Id
@SequenceGenerator(name = "ESCALADETALHE_S01", sequenceName = "ESCALADETALHE_S01")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "ESCALADETALHE_S01")
@Column(name = "IDPAI", unique = true, nullable = false, precision = 9, scale = 0)
private Integer idDetalhe;
@ManyToOne(cascade = CascadeType.ALL, optional = false)
@JoinColumn(name ="idEscala")
private EscalaBean escala;
@Temporal(TemporalType.DATE)
@Column(name = "dia")
private Calendar dia;
@OneToMany(fetch = FetchType.LAZY ,orphanRemoval = true,cascade = CascadeType.ALL, targetEntity = EscalaDiaBean.class )
@JoinColumn(referencedColumnName = "id.escalaDia")
private List<EscalaDiaDetalheBean> escalaDiaDetalhes;
//getters , setters, hash and equals
}
它必须为EscalaDiaDetalheBean
获得一个具有EscalaDiaDetalhePK
中声明的组合键的关系{@ToOney},如下所示:
@Embeddable
public class EscalaDiaDetalhePK implements Serializable {
@ManyToOne()
public TurmaBean turma;
@ManyToOne()
public EscalaDiaBean escalaDia;
//getters , setters, hash and equals
}
所以,我有clild实体:
@Entity
@Table(name = "DEFINICAOESCALA")
@AssociationOverrides(
value = {
@AssociationOverride(name = "id.turma", joinColumns = @JoinColumn(name ="idTurma")),
@AssociationOverride(name = "id.escalaDia", joinColumns = @JoinColumn(name ="idEscalaDia")),
}
)
public class EscalaDiaDetalheBean implements Serializable {
@EmbeddedId
public EscalaDiaDetalhePK id;
@ManyToOne(cascade = CascadeType.ALL)
public TurnoBean turno;
}
与EscalaDiaDetalheBean建立关系EscalaDiaBean
的正确方法是什么?
按照下面所述的方式,我得到无法在org.hibernate.mapping.Table(ESCALADETALHE)及其相关的超表和辅助表中找到逻辑名称为id.escalaDia的列 >
@OneToMany(fetch = FetchType.LAZY ,orphanRemoval = true,cascade = CascadeType.ALL, targetEntity = EscalaDiaBean.class )
@JoinColumn(referencedColumnName = "id.escalaDia")
private List<EscalaDiaDetalheBean> escalaDiaDetalhes;