Liam Clarke (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-10683 (
https://hibernate.atlassian.net/browse/HHH-10683?atlOrigin=eyJpIjoiZWI1ZD...
)
Re: Pooled id generation optimizer is causing ids from sequences to be reused (
https://hibernate.atlassian.net/browse/HHH-10683?atlOrigin=eyJpIjoiZWI1ZD...
)
I’ve just hit this issue in Hibernate 5.4.12 Final (upgraded from Hibernate 4.3.x) against
Postgres, same symptom - Hibernate attempts to insert a PK that is the DBs’s nextval -
allocationSize (which defaults to 50 on the JPA @SequenceGenerator annotation). We didn’t
have the same issue with Hibernate 4.3
insert into BACKFILL (HTML, IS_USED, ID) values (NULL, 'FALSE', 12029) was
aborted: ERROR: duplicate key value violates unique constraint
...
psql (11.5 (Debian 11.5-3.pgdg90+1))
Type "help" for help.
test=> select nextval('backfill_seq');
nextval
---------
12079
(1 row)
Setting hibernate.id.optimizer.pooled.prefer_lo to true as mentioned by the original
reporter also fixed the issue for me. I will try to attach a unit test to reproduce when I
get time.
(
https://hibernate.atlassian.net/browse/HHH-10683#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-10683#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100122- sha1:52999ef )