Unique index or primary key violation

39 views
Skip to first unread message

Ted Yu

unread,
Mar 14, 2023, 5:06:04 AM3/14/23
to H2 Database
Hi,
I am facing the following error when writing to a table via hibernate:
03/11/23 19:44:52 808 ERROR SqlExceptionHelper: Unique index or primary key violation: "PRIMARY_KEY_6 ON PUBLIC.AD(ACCU_ID, TARGET_ID, REPLAY_ID) VALUES (8, 24, 1, 7)"; SQL statement:
insert into ad (end_time, start_time, accu_id, target_id, replay_id) values (?, ?, ?, ?, ?) [23505-192]


I wonder what the 7 in 
(8, 24, 1, 7) means. (ACCU_ID, TARGET_ID, REPLAY_ID) has 3 columns (the primary key for ad table). It is a bit strange why a fourth number shows up.

Thanks

Evgenij Ryazanov

unread,
Mar 14, 2023, 6:41:33 AM3/14/23
to H2 Database
Hi!

It doesn't look like an original error from H2, H2 produces messages like Unique index or primary key violation: "PRIMARY_KEY_6 ON PUBLIC.AD(ACCU_ID, TARGET_ID, REPLAY_ID) VALUES ( /* key:1 */ 2, 3, 4), where 1 is an internal row number (_ROWID_) and other values are values of primary key columns.

Please note that H2 1.4.192 is a very old unsupported version of H2 database.
Reply all
Reply to author
Forward
0 new messages