Re: Problems with CommitChanges and object PersistenceState

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jan 28 2005 - 09:02:54 EST

  • Next message: Andrus Adamchik: "Re: CLOB and MySQL"

    Hi Laila,

    That's bizarre... Does it also happen with Cayenne 1.1 final? Also can you
    turn on SQL logging and post the full output during commit, including PK
    generation phase?

    If this doesn't help, please open a bug report with relevant mapping and
    sample code attached... Looking at ObjectStore.objectsCommitted(..), I can
    see one place that *theoretically* can lead to this problem, but I can't
    think of a reproducable test case for it...

    Thanks
    Andrus

    > The context used is the same everywhere.
    > This is the correct code example, where I add a System.out.println after
    > the first commit
    >
    > context =
    > org.objectstyle.cayenne.access.DataContext.createDataContext(); prn =
    > (PendingRawNews)context.createAndRegisterNewObject(PendingRawNews.class);
    > context.commitChanges();
    > System.out.println(context.newObjects());
    >
    > // ..... create other objects in the same context
    >
    > context.commitChanges();
    >
    >
    > This is the output of the println
    >
    > [{
    > [insertionDate => Fri Jan 28 09:43:29 CET 2005]
    > <oid: com.extrapola.scooter.dataModel.PendingRawNews: <ID: 982>;
    > state: new>
    > }]
    >
    > I'm using cayenne 1.1rc2
    >
    > Thank's
    > Laila
    >
    >
    > On Thu, 27 Jan 2005 23:38:51 -0500, Andrus Adamchik
    > <andru..bjectstyle.org> wrote:
    >>
    >> On Jan 27, 2005, at 7:48 AM, laila paganelli wrote:
    >>
    >> > context =
    >> > org.objectstyle.cayenne.access.DataContext.createDataContext();
    >> > prn =
    >> > (PendingRawNews)this.dataContext().createAndRegisterNewObject(PendingRa
    >> wNews.class);
    >>
    >>
    >> > After the first commit the object prn is saved on the database, but
    >> the state is still PersistenceState.NEW, while I expect it to be
    >> PersistenceState.COMMITTED.
    >> > After the second commit I find one more prn object on database.
    >> Why? What is wrong?
    >>
    >> Is it possible that "context" in the first line and
    >> "this.dataContext()" on the second are two different objects? Try
    >> rewriting the code to make sure the same context is used everywhere.
    >> E.g.:
    >>
    >> context = DataContext.createDataContext();
    >> prn = (PendingRawNews)
    >> context.createAndRegisterNewObject(PendingRawNews.class);
    >>
    >> Cheers,
    >> Andrus
    >>



    This archive was generated by hypermail 2.0.0 : Fri Jan 28 2005 - 09:02:55 EST