Re: Problems with CommitChanges and object PersistenceState

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jan 27 2005 - 23:38:51 EST

  • Next message: laila paganelli: "Re: Problems with CommitChanges and object PersistenceState"

    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 : Thu Jan 27 2005 - 23:38:56 EST