I think I may have run into an issue that is related to this thread:
http://markmail.org/message/slm4joyswjp77vzi
- I have an (abstract) entity A and two subentities/subclasses A1 and A2.
- I have an (abstract) entity B with three subentities B1, B2 and B3.
- There is a 1:n relationship from A to B.
Now, if I create an instance of A1 and use addToB() to add a B1 instance,
B1 is added to the list. But I get a validation error because upon
commit the foreign key for the A1 instance is not set on the B1 instance.
Debugging, I found that ObjRelationship.getReverseRelationship() didn't
look in super entities for the reverse relationship.
Mindlessly changing that method (in Trunk) from:
Entity src = this.getSourceEntity();
Iterator<?> it = target.getRelationships().iterator();
while (it.hasNext()) {
ObjRelationship rel = (ObjRelationship) it.next();
if (rel.getTargetEntity() != src)
continue;
to:
Entity src = this.getSourceEntity();
Iterator<?> it = target.getRelationships().iterator();
while (it.hasNext()) {
ObjRelationship rel = (ObjRelationship) it.next();
Entity relTarget = rel.getTargetEntity();
ObjEntity currentSrc = (ObjEntity)src;
while (currentSrc != null) {
if (relTarget == currentSrc) {
break;
}
currentSrc = currentSrc.getSuperEntity();
}
if (src == null) {
continue;
}
...solves my immediate problem, but I have no idea about any
side-effects. Am I doing anything wrong?
Thanks,
Jeremias Maerki
This archive was generated by hypermail 2.0.0 : Fri Aug 14 2009 - 09:19:49 EDT