Re: addToMany

From: Cyril Godefroy (cgodefro..ac.com)
Date: Wed Aug 11 2004 - 09:09:16 EDT

  • Next message: Eric Schneider: "Re: addToMany"

    Sorry, I meant all code, and that means also the interesting pieces in
    Forum.java.

    Check that addToThreads(Thread obj) method looks like:
            addToManyTarget("threads", obj, true);
    }

    This is where the magic happens.

    Also, is your forum property declared as persistent in your page spec?
    If not, getForum will definitely return null on going back from the
    browser to the app, and the forum_id will never be properly set... In
    such a case, it will be a tapestry issue, rather than a cayenne one.
    You should test outside of tapestry.

    Cyril

    On Aug 11, 2004, at 2:38 PM, Todd O'Bryan wrote:

    > public void createThread(IRequestCycle cycle) {
    > DataContext dc = ((Visit) getVisit()).getDataContext();
    > Thread thread = (Thread) dc.createAndRegisterNewObject(Thread.class);
    > thread.setName(getNewThreadName());
    > getForum().addToThreads(thread);
    > dc.commitChanges();
    > return;
    > }
    >
    > That's my createThread() method in the context of a Tapestry webapp,
    > so getForum() returns the forum that the user clicked on to get to
    > this page.
    >
    > Todd
    >
    > On Aug 11, 2004, at 7:19 AM, Cyril Godefroy wrote:
    >
    >>
    >> Could you send your code, because the rest of it is fine?
    >>
    >>
    >> On Aug 11, 2004, at 12:08 PM, Todd O'Bryan wrote:
    >>
    >>> I'm still not getting relationships...
    >>>
    >>> I'm modeling a simple bulletin board system.
    >>>
    >>> There are Forums which have Threads which have Messages.
    >>>
    >>> The thread table has a forum_id field and there's a relationship
    >>> called forum from thread to forum with a reverse to-many
    >>> relationship called threads from forum to thread.
    >>>
    >>> I fetch aForum, create aThread, and call
    >>> aForum.addToThreads(aThread). The thread shows up in the database,
    >>> but the forum_id is not correctly set to the id of aForum. Is this
    >>> something I have to do manually or should it be happening
    >>> automatically? It seems the latter, but maybe not...
    >>>
    >>> Thanks,
    >>> Todd
    >>>
    >





    This archive was generated by hypermail 2.0.0 : Wed Aug 11 2004 - 09:09:23 EDT