Re: Problem with reverse relationships and inheritance

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Aug 26 2009 - 10:58:47 EDT

  • Next message: Andrus Adamchik: "Re: Junit sometimes failes"

    Yeah, sorry about messing that up :-)

    On Aug 26, 2009, at 5:39 PM, Andrey Razumovsky wrote:

    > BTW, it seems my problems were caused by another code, that
    > belonging to
    > CAY-132. As now this is fixed on the trunk, we can proceed with that
    > one
    >
    > 2009/8/17 Jeremias Maerki <de..eremias-maerki.ch>
    >
    >> Thanks, Andrey. I somehow missed that. I'll see if I can allocate
    >> time
    >> to write a test case. That could help speed things up.
    >>
    >> On 16.08.2009 22:01:17 Andrey Razumovsky wrote:
    >>> 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
    >>>>
    >>>>
    >>
    >>
    >>
    >>
    >> Jeremias Maerki
    >>
    >>



    This archive was generated by hypermail 2.0.0 : Wed Aug 26 2009 - 10:59:25 EDT