cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Lewis <br...@maine.rr.com>
Subject Re: PK problem with Postgre
Date Thu, 20 Apr 2006 14:30:10 GMT
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:43
>9)
>
>Message: *** error.
>
>org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
>constraint "image_pk"
>
>at
>org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorI
>mpl.java:1513)
>
>at
>  
>


Mime
View raw message