cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes <jotpe....@gmail.com>
Subject double primary key exception
Date Mon, 22 Dec 2014 21:19:29 GMT
Hello!

In some circumstances, which I don't know exactly, I have problems with
my sequences. It believe the postgres nextval is not called and with
some magic the next pk is incremented by something else.

Here the data:
I have a many-to-many relationship:

table:israelnationaltrail  join_intcat         category
seq:                       join_intcat_id_seq  category_id_seq
      -------------------  -----------         --------
      id PK                id PK               id PK
      ...                  int_id FK <-        ...
                           cat_id FK ->

The sequences are registered as custom sequence in cayenne modeler.

My postgres log. As you can see at Category "Weberkogel" and "Gates in
Israel" there is no logged select nextval();

2014-12-22 16:22:21 CET LOG:  Ausführen <unnamed>: SELECT
nextval('category_id_seq')
2014-12-22 16:22:21 CET LOG:  Ausführen <unnamed>: INSERT INTO
"public"."category" ("id", "name") VALUES ($1, $2)
2014-12-22 16:22:21 CET DETAIL:  Parameter: $1 = '59', $2 = ''
...
2014-12-22 17:23:31 CET LOG:  Ausführen <unnamed>: SELECT
nextval('category_id_seq')
2014-12-22 17:23:31 CET LOG:  Ausführen <unnamed>: INSERT INTO
"public"."category" ("id", "name") VALUES ($1, $2)
2014-12-22 17:23:31 CET DETAIL:  Parameter: $1 = '60', $2 = 'Golan Heights'
...
2014-12-22 17:45:30 CET LOG:  Ausführen <unnamed>: INSERT INTO
"public"."category" ("id", "name") VALUES ($1, $2)
2014-12-22 17:45:30 CET DETAIL:  Parameter: $1 = '61', $2 = 'Weberkogel'
...
2014-12-22 17:45:42 CET LOG:  Ausführen <unnamed>: INSERT INTO
"public"."category" ("id", "name") VALUES ($1, $2)
2014-12-22 17:45:42 CET DETAIL:  Parameter: $1 = '62', $2 = 'Gates in
Israel'
...
2014-12-22 21:16:56 CET LOG:  Ausführen <unnamed>: SELECT
nextval('category_id_seq')
2014-12-22 21:16:56 CET LOG:  Ausführen <unnamed>: INSERT INTO
"public"."category" ("id", "name") VALUES ($1, $2)
2014-12-22 21:16:56 CET DETAIL:  Parameter: $1 = '62', $2 =
'International borders of Lebanon'
2014-12-22 21:16:56 CET FEHLER:  doppelter Schlüsselwert verletzt
Unique-Constraint »category_pkey«
2014-12-22 21:16:56 CET DETAIL:  Schlüssel »(id)=(62)« existiert bereits.
2014-12-22 21:16:56 CET ANWEISUNG:  INSERT INTO "public"."category"
("id", "name") VALUES ($1, $2)
2014-12-22 21:16:56 CET LOG:  Ausführen S_3: ROLLBACK


test=> select * from category_id_seq ;
   sequence_name   | last_value | start_value | increment_by |
max_value      | min_value | cache_value | log_cnt | is_cycled | is_called
-------------------+------------+-------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 categories_id_seq |         62 |           1 |            1 |
9223372036854775807 |         1 |           1 |      32 | f         | t
(1 Zeile)


test=> select * from category where id >= 59;
 id |      name
----+-----------------
 59 |
 60 | Golan Heights
 61 | Weberkogel
 62 | Gates in Israel
(4 Zeilen)



Mime
View raw message