我有 4 个类实体:CtPersonaFirma、CtFirmaDocumento 和 CtContrato。一个人可以签订多份合同,一份合同可以由多人签订。
CtPersonaFirma:包含授权签署的人员。
CtContrato:包含合约
CtFirmaDocumento:上面两张表的关系。
当我删除一个人时,用于级联的 CtPersonaFirma 表删除了 CtFirmaDocumento 表,其中有对已删除人员的引用,但在实体 CtContrato 的集合 ctFirmaDocumentoCollection 中未更新。
public class CtContrato implements Serializable {
@Id
@Basic(optional = false)
@NotNull
@Column(name = "id_contrato")
private Integer idContrato;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "ctContrato", fetch=FetchType.LAZY)
private Collection<CtFirmaDocumento> ctFirmaDocumentoCollection;
public class CtPersonaFirma implements Serializable {
@Id
@Basic(optional = false)
@NotNull
@Column(name = "id_persona")
private Integer idPersona;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "ctPersonaFirma")
private Collection<CtFirmaDocumento> ctFirmaDocumentoCollection;
public class CtFirmaDocumento implements Serializable {
@EmbeddedId
protected CtFirmaDocumentoPK ctFirmaDocumentoPK;
@JoinColumn(name = "id_persona_ref", referencedColumnName = "id_persona", insertable = false, updatable = false)
@ManyToOne(optional = false)
private CtPersonaFirma ctPersonaFirma;
@JoinColumn(name = "id_contrato", referencedColumnName = "id_contrato", insertable = false, updatable = false)
@ManyToOne(optional = false)
private CtContrato ctContrato;