Re: EO advice
Re: EO advice
- Subject: Re: EO advice
- From: Theodore Petrosky <email@hidden>
- Date: Fri, 06 Jun 2014 10:43:31 -0400
the wiki touches on this
When overriding awakeFromInsertion(...) there are two times that this method can be called when the EO being inserted is not actually being initialized for the first time.- If it's being reinserted to a EC after it was deleted from another or the same EC. Only new EOs will have a temporary GlobalID.
If it's being saved to the server-side application by a Java Client WebObjects application. These EOs will have been inserted on the client-side and likely already have values set. To avoid overriding these values, you should verify that the attribute's value is null first.
and it gives a code example of checking if the globalIDForObject isTemporary
so it seems to me that the answer is to use awakeFromInsertion, but do the check to be sure that the global id is NOT temporary or rather, in my case put my relationship creation code in a block that first checks if the global id is temporary as I only want this to run when I create a new EO.
@Override public void awakeFromInsertion(EOEditingContext ec) { super.awakeFromInsertion(ec); EOGlobalID gid = ec.globalIDForObject(this);
if(gid.isTemporary()) {
for (Person aPerson: Person.fetchPersons(ec, Person.IS_PRIMARY.eq(true).and(Person.CURRENT.eq(true)), null)) { ShowPerson.createShowPerson(ec, aPerson, this); } }
}
Thanks for sharing Ken and John!! On Jun 6, 2014, at 10:22 AM, Ken Anderson < email@hidden> wrote: Well OK then! Someone should up the commandments. Thanks John. On Jun 6, 2014, at 10:21 AM, John Huss < email@hidden> wrote: Except awakeFromInsertion is buggy and replaced by init in Wonder:
/** * used for initialization stuff instead of awakeFromInsertion. * <code>awakeFromInsertions</code> is buggy because if an EO is deleted
* and then its EOEditingContext is reverted using 'revert' for example then * EOF will -insert- this EO again in its EOEditingContext which in turn * calls awakeFromInsertion again.
* / protected void init(EOEditingContext ec)
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden