Re: Modeling an optional to-one relationship
Re: Modeling an optional to-one relationship
- Subject: Re: Modeling an optional to-one relationship
- From: Mark Ritchie <email@hidden>
- Date: Fri, 15 Jan 2010 00:08:06 -0800
Hi Chuck!
On 14/Jan/2010, at 1:46 PM, Chuck Hill wrote:
> On Jan 14, 2010, at 3:36 AM, Mark Ritchie wrote:
>> Yes, I believe that's the intended behaviour... The DatabaseContext tracks that newly created EO and throws an exception if you attempt to modify and then save it.
> Almost, it throws when the fault is fired.
Hrm, in test case that I constructed, that's not what I observe.
I'm using WOF 5.4.3, Java 1.5 on my development machine.
Using the Movies EOModel and local mysql:
I fetch a Talent EO.
I ask for it's photo and get back a fault for the TalentPhoto EO (as expected.)
I fire the fault and get back a TalentPhoto EO with PK set and nil values.
EODatabaseContext.objectsWithMissingGlobalIds() confirms that it's tracking the TalentPhoto EO for me.
I make a change to the Talent EO and save it.
All is good.
I make changes to TalentPhoto:set a photo and set it's talent relationship to the Talent EO.
Then when I try to save changes, EOF tosses a EOObjectNotAvailableException with this explanation:
prepareForSaveWithCoordinator: Cannot save the object with globalID _EOIntegralKeyGlobalID[TalentPhoto (java.lang.Integer)1]. The row referenced by this globalID was missing from the database at the time a fetch was attempted. Either it was removed from the database after this application got a pointer to it, or there is a referential integrity problem with your database. To be notified when fetches fail, implement a delegate on EODatabaseContext that responds to databaseContextFailedToFetchObject().
That explanation seems to match what I've done and the behaviour seems to match the documentation for EODatabaseContext's delegate databaseContextFailedToFetchObject(). http://tr.im/dcdelegate
What am I doing differently then you?
M.
_______________________________________________
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