Relationship across DataDomains (again)

From: Todd O'Bryan (toddobrya..ac.com)
Date: Wed Sep 08 2004 - 20:48:12 EDT

  • Next message: Andrus Adamchik: "Re: Relationship across DataDomains (again)"

    After a weekend of illness, too much time spent creating interesting
    problem sets for my intro to programming classes, grading a
    horrendously written quiz that took waaaaay too much time to grade, and
    generally not getting to do any real coding of my own, I'm finally back
    to the problem I mentioned a while ago.

    I stuck methods in my classes to handle the relationships the modeler
    didn't create, but I seem to have missed something. Here's the
    exception with the first few objects in the stack trace:

    Unable to invoke method postNewMessage on
    org.dupontmanual.web.forum.ShowThread$Enhance_1..ef658[ShowThread]:
    Can't find relationship: poster
            •
             
    org.objectstyle.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObje
    ct.java:358)
            • org.dupontmanual.cayenne.forum.Message.setPoster(Message.java:10)
            •
    org.dupontmanual.web.forum.ShowThread.postNewMessage(ShowThread.java:
    41)

    Here are (what I think are) the relevant parts of Forum.map.xml and
    User.map.xml, the two DataDomain descriptors:

            <db-relationship name="poster" source="message" target="user"
    toMany="false">
                    <db-attribute-pair source="poster_id" target="id"/>
            </db-relationship>

            <db-relationship name="messages" source="user" target="message"
    toMany="true">
                    <db-attribute-pair source="id" target="poster_id"/>
            </db-relationship>

    And the relevant code that I put in Message.java

            public static final String POSTER_PROPERTY = "poster";
            
         public void setPoster(org.dupontmanual.cayenne.users.User poster) {
             setToOneTarget("poster", poster, true);
         }

         public org.dupontmanual.cayenne.users.User getPoster() {
             return
    (org.dupontmanual.cayenne.users.User)readProperty("poster");
         }

    Anything jump out that I'm doing wrong?

    Thanks, especially after such a long time to forget about the original
    problem,
    Todd



    This archive was generated by hypermail 2.0.0 : Wed Sep 08 2004 - 20:48:16 EDT