Re: postgres serial

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Feb 14 2005 - 19:15:26 EST

  • Next message: Cris Daniluk: "RE: postgres serial"

    You can't do this:

    > DataObjectUtils.intPKForObject(user);

    until you do this:

    > context.commitChanges();

    In fact, looking at your code, you don't need
    "DataObjectUtils.intPKForObject(user)" line at all - it doesn't
    accomplish anything, and without it everything else should just work.
    Cayenne generates PK automatically behind the scenes when you do
    commitChanges. You don't need to help it in any way. "intPkForObject"
    is intended to read and id once it is generated, so it is likely not
    applicable in your case.

    Andrus

    On Feb 14, 2005, at 7:00 PM, Koen Segers wrote:

    > What I have done allready:
    > • Generate Database Schema -> Create Primary key support for all
    > classes
    > • added this to source:
    > • Users user = (Users)
    > context.createAndRegisterNewObject(Users.class);
    > • DataObjectUtils.intPKForObject(user);
    > • user.setName(getUserName());
    > • user.setPassword(getPassword());
    > • user.setAuthlevel(getAuthLevelID());
    > • context.commitChanges();
    > • retrieved error:
    > • Unable to invoke method createUser on
    > website.CreateUse..e22632[CreateUser]: [v.1.1 December 6 2004] Can't
    > get primary key from temporary id.
    > • Stack Trace:
    > •
    > org.objectstyle.cayenne.DataObjectUtils.extractObjectId(DataObjectUtils
    > .java:139)
    > •
    > org.objectstyle.cayenne.DataObjectUtils.pkForObject(DataObjectUtils.jav
    > a:110)
    > •
    > org.objectstyle.cayenne.DataObjectUtils.intPKForObject(DataObjectUtils.
    > java:94)
    > • website.CreateUser.createUser(CreateUser.java:83)



    This archive was generated by hypermail 2.0.0 : Mon Feb 14 2005 - 19:15:32 EST