On Apr 14, 2012, at 4:17 PM, George Domurot wrote:
> In your code snip, you aren't adding the newContract object into the editing
> context. To reduce errors like these, always use:
>
Thanks, after I posted the code I noticed that error and added
eo,insert(newContract)
It still does not want to run.
I suppose there is some faulting going on: I noticed that the
if (contract()==null)
clause did not get triggered while fetching shows that did not have a contract.
> ERXEOControlUtilities.createAndInsertObject
>
> I'd recommend not doing this in awakeFromFetch, but making this a step in
> your migration to clean-up your DB/object graph. 1,500 new objects is a
> light amount of processing and will keep your model object's code clean.
>
> -G
I know that would be a simpler solution, (and propably will do it) but I am
still curious why the code does not work.
>
>
> On Apr 14, 2012, at 1:52 AM, Johan Henselmans wrote:
>
>> 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
>> [email protected]
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/mastermind%40knuckleheads.net
>>
>> This email sent to [email protected]
>
Vriendelijke Groeten,
Johan Henselmans
[email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]