Re: missing reverse relationship causes NPE

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Nov 08 2002 - 10:52:15 EST

  • Next message: Holger Hoffstätte: "Tip: running Modeler from eclipse"

    Hmm, I need to look at that. I thought we'd fixed most of the problems in
    this area. I agree with your ideas though. Will get back on this later.

    Andrus

    Dirk Olmes writes:
    > Hi,
    >
    > while playing around with reflexive relationships I encountered a strange
    > NullPointerException:
    >
    > java.lang.NullPointerException
    > at
    > org.objectstyle.cayenne.QueryHelper.selectRelationshipObjects(QueryHelper.java:280)
    > at
    > org.objectstyle.cayenne.access.util.RelationshipDataSource.updateListData(RelationshipDataSource.java:86)
    > at
    > org.objectstyle.cayenne.access.ToManyList.getObjectList(ToManyList.java:113)
    > at org.objectstyle.cayenne.access.ToManyList.iterator(ToManyList.java:187)
    > at bm.MissingBackRelationship.main(MissingBackRelationship.java:33)
    >
    > The same bug shows up in normal relationships as well.
    >
    > A closer look into the source reveals that
    > DBRelationship::getReverseRelationship() is indeed
    > allowed to return null. The code in QueryHelper however does not check the
    > return value but
    > happily calls srcFkSnapshotWithTargetSnapshot().
    >
    > The workaround would be to model the reverse relationshpip in the
    > DBEntity.... I wonder
    > however if there is a reason for requiring both relationships to be present:
    > in EOF
    > this could cause the most infamous "add to to-many relationship" bug.
    >
    > Could this effect also show up in Cayenne?
    >
    > A possible better implementation could be to not rely on the reverse
    > relationship to be present
    > but simply create a temporary relationship and use that for resolving the
    > to-many....
    >
    > -dirk
    >
    > --
    > +++ GMX - Mail, Messaging & more http://www.gmx.net +++
    > NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
    >
     



    This archive was generated by hypermail 2.0.0 : Fri Nov 08 2002 - 10:52:20 EST