Re: postgres serial

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Feb 13 2005 - 18:58:47 EST

  • Next message: Andrus Adamchik: "Re: One Transaction for select and update"

    > newcourse.setID(/*whatnumber*/);

    You don't need this line - Cayenne will generate PK for you. Unless you
    have a really good reason to do that, I will go further and recommend
    to remove ID attribute from Java class and let Cayenne handle it all
    the way. If you need to read generated ID, use DataObjectUtils -
    http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/
    DataObjectUtils.html

    Andrus

    On Feb 13, 2005, at 10:13 AM, Koen Segers wrote:

    > Hi,
    >
    > I used phpPgAdmin to create my database. I used a serial type to
    > increment the
    > id automaticly. It creates automaticly a sequence.
    >
    > Now I want to insert a field with cayenne. How can request the id?
    > Course newcourse = (Course)
    > context.createAndRegisterNewObject(Course.class);
    > newcourse.setID(/*whatnumber*/);
    >
    > Greetz
    > --
    >
    > Koen Segers
    >
    > <koenseger..carlet.be>
    > <http://eddyvite.dyndns.org>



    This archive was generated by hypermail 2.0.0 : Sun Feb 13 2005 - 18:58:51 EST