Re: PK problem with Postgre

From: WONDER (mmmmmmmmm5..eb.de)
Date: Thu Apr 20 2006 - 10:59:28 EDT

  • Next message: WONDER: "Re: PK problem with Postgre"

    My table has no higher PKs.
    Its Cayenne or PostGre which does not use the seq correctly. so once it
    increments the seq and another not.
    Dont ask me why, otherwise I would be able to solve the problem :)

    thx.
    ----- Original Message -----
    From: "Bryan Lewis" <brya..aine.rr.com>
    To: <cayenne-use..ncubator.apache.org>
    Sent: Thursday, April 20, 2006 4:30 PM
    Subject: Re: PK problem with Postgre

    > Here's my guess. Your image table had some existing data before you
    > added the sequence for Cayenne's use. When the modeler adds a sequence,
    > it defaults to a starting value of 200, with SQL like this:
    >
    > CREATE SEQUENCE pk_image START WITH 200 INCREMENT BY 20;
    >
    > If your table already had primary keys with values of 200 and above,
    > you'll get an occasional error like the one you saw. You can check this
    > by looking at the log just before the error; you'll see what primary key
    > the SQL is trying to assign.
    >
    > The fix would be to adjust the start value for the sequence to be higher
    > than any value in the table.
    >
    >
    > WONDER wrote:
    >
    > >Hi,
    > >
    > >I have problem with PostGreSQL ver 8.1.3 using JDBC ver 8.2dev-501 JDBC 3
    > >and Cayenne 1.2.B2.
    > >
    > >I use the Default Strategy to create the PKs using Cayenne. in the DB, i
    > >created the SEQ : pk_TableName. like pk_image for Table image.
    > >
    > >Sometimes I get the following error and sometimes it just work.
    > >Till now, I coulding find the logic behind.
    > >
    > >Anybody can help?
    > >Thanks.
    > >
    > >-------------------------------------------------
    > >Priority : INFO
    > >
    > >Class.Method(line):
    >
    >org.objectstyle.cayenne.access.QueryLogger.logQueryError(QueryLogger.java:4
    3
    > >9)
    > >
    > >Message: *** error.
    > >
    > >org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
    > >constraint "image_pk"
    > >
    > >at
    >
    >org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutor
    I
    > >mpl.java:1513)
    > >
    > >at
    > >
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Apr 20 2006 - 11:00:22 EDT