Re: Inheritance and stale relationship
Re: Inheritance and stale relationship
- Subject: Re: Inheritance and stale relationship
- From: Denis Frolov <email@hidden>
- Date: Thu, 2 Aug 2007 19:14:15 +0400
On Aug 2, 2007, at 4:37 PM, Ken Anderson wrote:
On Aug 2, 2007, at 6:19 AM, Denis Frolov wrote:
Article is a child entity of OfficeItem (using horizontal
inheritance here)
Office.officeItems <-->> OfficeItem
Office.articles <-->> Article
1. I create a new Article object and add it to both sides of
Office.officeItems relationship.
2. Office.officeItems relationship is updated as expected and I
can see new Article object there.
3. Office.articles relationship is not updated and I cannot see
new Article there.
I've noticed, that sometimes Office.articles does get updated, but
I haven't yet found the reason why. I seem to be doing the same
steps to reproduce the problem but am getting different results.
Any clues? What part of EOF is supposed to update Office.articles
relationship?
None.
You are doing something that EOF doesn't expect - having
relationships that reference a super-entity and a sub-entity. The
only way this would really work is if you add your object to both
sides of both relationships.
The reason you're seeing unpredictable behavior is because, if the
articles relationship hasn't been faulted yet, EOF will go to the
database and end up fetching the same object that you originally
attached to the officeItems relationship.
As far as I can see the fault has already fired and there is no trip
to the database.
I would strong think about why you need to have 2 such
relationships. A better solution would be to have the officeItems
relationship, then have a method that creates a new array for
articles whenever you need them.
Using multiple relationships was convenient since in e.g. D2W CRUD
interface I could use Office's sub-entity relationships to
ContentItems (e.g. Article, File, etc) to add/remove objects and
could use officeItems relationship to list all the officeItems of
Office.
I will refactor to arrays as you suggest - just wanted to make sure
that this behavior is not supported by EOF. Thanks for help!
Ken
--
Denis
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
This email sent to email@hidden
--
Denis
_______________________________________________
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