@Entity
@DynamicInsert
@DynamicUpdate
@SelectBeforeUpdate
@Table(name="CONTRACTS")
@Audited
public class Contract implements Serializable {
private static final long serialVersionUID = 1L;
private List<DesignContract> designs;
@OneToMany(mappedBy = "pk.contract", fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, orphanRemoval=true)
@Fetch(value = FetchMode.SUBSELECT)
public List<DesignContract> getDesigns() {
return designs;
}
public void setDesigns(List<DesignContract> designs) {
this.designs= designs;
}
}
@Entity
@AssociationOverrides({
@AssociationOverride(name = "pk.contract",
joinColumns = @JoinColumn(name = "FK_CONTRACT")),
@AssociationOverride(name = "pk.design",
joinColumns = @JoinColumn(name = "FK_DESIGN")) })
@Table(name="CONTRACT_DESIGNS")
@Audited
public class DesignContract implements Serializable {
private static final long serialVersionUID = 1L;
public DesignContract () {
}
public DesignContract (Contract contract, Design design) {
pk.setContract(contract);
pk.setDesign(design);
}
private DesignContractId pk = new DesignContractId();
@EmbeddedId
public DesignContractId getPk() {
return pk;
}
public void setPk(DesignContractId pk) {
this.pk = pk;
}
@Transient
public Contract getContract() {
return getPk().getContract();
}
public void setContract(Contract contract) {
getPk().setContract(contract);
}
@Transient
public Design getDesign() {
return getPk().getDesign();
}
public void setDesign(Design design) {
getPk().setDesign(design);
}
private Double goal;
@Column(name = "GOAL", nullable = true, insertable = true, updatable = true, precision = 5, scale = 2)
@Basic
public Double getGoal() {
return this.goal;
}
public void setGoal(Double goal) {
this.goal = goal;
}
}
@Embeddable
public class DesignContractId implements Serializable {
private static final long serialVersionUID = 1L;
private Contract contract;
private Design design;
@ManyToOne
public Contract getContract() {
return contract;
}
public void setContract(Contract contract) {
this.contract = contract;
}
@ManyToOne
public Design getDesign() {
return design;
}
public void setDesign(Design design) {
this.design = design;
}
}