cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Lewis <>
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:


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:

>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?
>Priority : INFO
>Message: *** error.
>org.postgresql.util.PSQLException: ERROR: duplicate key violates unique
>constraint "image_pk"

View raw message