Inheritance and inverse relationships
Inheritance and inverse relationships
- Subject: Inheritance and inverse relationships
- From: Johann Werner <email@hidden>
- Date: Sun, 26 Dec 2010 16:13:44 +0100
Hi,
I hope everyone had a good Christmas.
During processing models and entities I stumbled upon a situation where I get an unexpected result. Basically I have an entity Parent with a subclass Child using single-table inheritance. Then I have another entity Gift that has a relation Parent <-->> Gift. Both relationships are marked as class attributes so Parent./Child.gifts() and Gift.presentee() return the correct objects.
Now I am processing the corresponding EOModel objects and when I have the model for Child doing:
EORelationship rel = childModel.relationshipNamed("gifts");
EORelationship inverseRelationship = rel.inverseRelationship();
leaves inverseRelationship with a null value though it should have been set to the presentee-relationship. Digging into EORelationship. inverseRelationship() reveals that it compares the entity (Child in this case) with the destination entities from Gift. Too bad that it resolves to Parent so EOF simply says that there is no matching inverse. Seems as a bug to me. It should check for entity equality and then equality with any subclass if present. Any thoughts?
I found the method EORelationship.anyInverseRelationship() that returns an internal inverse but of course that is not really useful when calling valueForKey on an object with the returned key name later on.
jw
_______________________________________________
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