Re: Postgres auto sequences

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jan 05 2006 - 08:56:15 EST

  • Next message: Andrus Adamchik: "M10 is out"

    Hmm.. I can't make sense of your description of the problem, so I'll
    give the generic answer.

    By default 1.2 Postgres adapter uses sequences, but the names are
    assigned by Cayenne ("Default Strategy"). "Database Generated" is not
    applicable for Postgres. Finally custom sequence is the same as
    default, only allows you to map pk generation to sequences that you
    create on your own. If you use that, make sure that "Cache PK Size"
    is the same as the actual "Increment By".

    Finally when you mention that Cayenne does this or that, it would
    help if you include SQL log as it shows what really happens:

    http://objectstyle.org/cayenne/userguide/deploy/logging.html

    Andrus

    On Jan 5, 2006, at 7:55 AM, Lindsay Steele wrote:

    > Has anyone successfully used any sort of data generated sequences in
    > Postgresql ? (8.1.1)
    >
    > I am running into a problem, if I set the PK Generation strategy to
    > default, then it seems to want to look for an auto generated PK table,
    > which I am not using. If I can get away with it, I would prefer
    > not to
    > use auto PK support.
    >
    > If I set the modeler to "Database Generated", then it does the same
    > thing. It tries to look for an auto generated PK Table.
    >
    > If I used the custom sequence and point it at the sequences that
    > Postgres uses internally, then it will do the first insert but
    > Postgres
    > will not update it's sequence number. My testing and information
    > from
    > Postgres users tells me that the problem here is that cayenne is
    > trying
    > to do an insert by specifying the PK. This somehow bypasses Postgres
    > updating it's sequence number internally. This continues to work
    > for a
    > while as cayenne must keep track of what the last insert was
    > internally
    > - but as soon as you restart the app server, information is lost and
    > subsequent inserts fail. When you do an insert without specifying a
    > primary key the internal number is updated and things work as they
    > should.
    >
    > This problem is the same in both Windows and Linux. I am using the
    > modeler from M9 and have tried both the cayenne.jar from M8 and M9.
    >
    > Does anyone have this working, and if so how ?



    This archive was generated by hypermail 2.0.0 : Thu Jan 05 2006 - 08:56:19 EST