Re: Postgres auto sequences

From: Lindsay Steele (lsteel..inet.net.au)
Date: Fri Jan 06 2006 - 07:24:01 EST

  • Next message: Philip Miller: "RE: Note to Cayenne/Tapestry users ..."

    Setting the Cache PK Size to 1 fixes the problem - I was setting it
    higher because of a previous conversation on this list where it was
    mentioned that it was better to set it to a higher value for
    efficiency. I must be getting two things confused.

    Thanks for the help.

    Andrus Adamchik wrote:

    > 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 : Fri Jan 06 2006 - 07:23:07 EST