Re: Can a relationship return null?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Dec 12 2004 - 00:15:05 EST

  • Next message: Todd O'Bryan: "Re: Can a relationship return null?"

    Todd,

    >> Should a relationship *ever* return null, or should it just return an
    >> empty List if there's nothing in it?

    "To-many" - never. An empty list should be returned.

    Now back to your mapping... The only thing that is special about
    "getTeacherForums" is that the relationship is flattened... Still it is
    to-many, so it should be an empty list. So unless someone else spots
    the problem in the mapping, I'd say we should investigate this.

    Could you open a bug report, so that it doesn't get lost? Please attach
    any SQL run for the query to resolve the root User and also SQL for
    getTeacherForums() call (if any is generated at all). This should help
    to track it down.

    Andrus

    On Dec 11, 2004, at 11:53 PM, Todd O'Bryan wrote:

    > Whoops. Before I decided to send the xml's to the list, I was
    > simplifying a bit. It's actually getTeacherSections() that I can call
    > on User which works, and it's getTeacherForums() that doesn't. Sorry
    > about any confusion.
    >
    > Todd
    >
    > On Dec 11, 2004, at 11:46 PM, Todd O'Bryan wrote:
    >
    >> I have a rather convoluted relationship...
    >>
    >> A User maps to several Section objects, and each of these maps to
    >> several Forum objects. I created a forums relationship on User which
    >> is a chain from User to Section to a bridge table of Section and
    >> Forum ID's and then to Forum.
    >>
    >> When I call getSections() on User, it works fine.
    >> When I call getForums() on Section, it works fine.
    >> When I call getForums() on User, it returns null.
    >>
    >> Should a relationship *ever* return null, or should it just return an
    >> empty List if there's nothing in it?
    >>
    >> Todd
    >>
    >> P.S. Each of the three object entities is in a different
    >> DataMap...don't know if that makes a difference. I've also attached
    >> my xml files. Hopefully they'll make it to the list.
    >> <cayenne.xml><Courses.map.xml><Forums.map.xml><Users.map.xml>
    >>
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Sun Dec 12 2004 - 00:15:14 EST