RE: postgres serial

From: Cris Daniluk (cris.danilu..laraview.com)
Date: Mon Feb 14 2005 - 19:19:45 EST

  • Next message: Koen Segers: "Re: postgres serial"

    Presumably your problem is this:

    DataObjectUtils.intPKForObject(user);

    This retrieves a property... It doesn't actually do anything to user.
    Further, this property doesn't even exist until after the object is saved:

    http://www.objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/DataO
    bjectUtils.html#intPKForObject(org.objectstyle.cayenne.DataObject)

    Try leaving that line out. You may have trouble though, since you used a
    serial type. I'm not sure if Cayenne plays nicely with serial. It's fairly
    unique to Postgres and I haven't tested it much yet.

    Cris

            * 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.java: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:19:46 EST