I am working with shows, that should have contracts.
That was only discovered after some shows (let's say 1500) had already been in the database.
So I created a new entity Contract, that has a not null relation to show, get's it's primarykey propagated from the show which owns the destination. If the shows is deleted, the contract is deleted (Cascade), like so:
<PastedGraphic-9.png>
<PastedGraphic-8.png>
I thought that with the code:
public void awakeFromFetch(EOEditingContext eo){
if (contract()==null){
Contract newContract = new Contract();
newContract.setContractAmount(new BigDecimal(0.0));
newContract.setContractDescription("tempDescription");
newContract.setContractRemarks("tempRemarks");
newContract.setContractType(ContractTypeEnum.RENT);
setContractRelationship(newContract);
eo.saveChanges();
}
}
In the extended class of the _Show this would make sure that everything gets filled, in the case a contract has not been created as it does with new shows because it is an old show.
Alas, that does not seem to be the case. What should I do to create a contract the moment an old show does not have a contract?
Vriendelijke Groeten,
Johan Henselmans
Vriendelijke Groeten,
Johan Henselmans