Hi Jeremias,
This is also known as CAY-1009:
http://issues.apache.org/jira/browse/CAY-1009
I tried patch from there (and it looks like yours) but there WERE side
effects (I listed them in JIRA). At the moment I was forced to make the
relationship non-mandatory in my project (and validate in different ways). I
would really like to get it fixed, but I haven't found time for that yet...
Please watch the JIRA to be notified of the updates
Regards,
Andrey
2009/8/14 Jeremias Maerki <de..eremias-maerki.ch>
> 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 : Sun Aug 16 2009 - 16:01:58 EDT