Re: addToMany

From: Jürgen Saar (jsaa..eb.de)
Date: Thu Aug 12 2004 - 01:55:47 EDT

  • Next message: Reinaldo Coelho Sartorelli: "Re: Query Error in table with auto_pk_generation"

    I think the problem can be in getForum()

    I had a simular Problem:

    I had an Order-Object and added a Postion to the Position-Relation
    Then commited the changes
    Then took this Order-Object and added the next Position.
    The commit came up with some strange Exceptions.

    The thing I changed to solve this:
      I read the Order-Object again from Database
      and then added the next Position

    After that all works fine.

    Todd O'Bryan <toddobrya..ac.com> schrieb am 11.08.04 14:39:12:
    >
    > 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
    > >>
    >

    ____________________________________________________
    Aufnehmen, abschicken, nah sein - So einfach ist
    WEB.DE Video-Mail: http://freemail.web.de/?mc=021200



    This archive was generated by hypermail 2.0.0 : Thu Aug 12 2004 - 01:56:06 EDT