Nara Simha (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63f1102...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOTBiNjlmMzNh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16502?atlOrigin=eyJpIjoiOTBiNj...
) HHH-16502 (
https://hibernate.atlassian.net/browse/HHH-16502?atlOrigin=eyJpIjoiOTBiNj...
) Hib5: @OneToOne mapping with unique=true throws "caused a duplicate key value in a
unique or primary key constraint' (
https://hibernate.atlassian.net/browse/HHH-16502?atlOrigin=eyJpIjoiOTBiNj...
)
Issue Type: Bug Affects Versions: 5.2.18 Assignee: Unassigned Attachments:
dampen-20230424-054645 (7efd1ac9-095c-4083-a638-335bedcd1efd).png,
dampen-20230424-054645.png Components: hibernate-orm-modules, query-criteria Created:
23/Apr/2023 22:49 PM Environment: OS: CentOS Linux release 7.9.2009
JDK: 11, Zulu
EJB 3.1, Hibernate 5.2.x,
WildFly Core 22.08.004
Database: postgreSQL as well as HSQLDB Labels: JoinColumn foreignkey uniqueconstraint
Priority: Major Reporter: Nara Simha (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63f1102...
)
The following mapping works fine in Hib 3.x
@OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, optional = true)
@JoinColumn(name = PAYLOAD_FILTER_COLUMN, unique = true)
private PayloadFilterExpression payloadFilter;
*The same mapping throws the following error in Hib 5.x*
This table, NMS_DAMPEN_CONFIG has a one-to-one relationship with NMS_PAYLOAD_FILTER_EXPR
table.
This column, PAYLOAD_FILTER is populated based on index col value of
NMS_PAYLOAD_FILTER_EXPR
The unique key needs to be relaxed in order to proceed with the inserts else we hit the
following issue:
"2023-04-10 01:35:02.749 ERROR
[org.hibernate.engine.jdbc.batch.internal.BatchingBatch] HHH000315:
Exception executing batch [java.sql.BatchUpdateException: The statement was aborted
because it would
have caused a duplicate key value in a unique or primary key constraint or unique index
identified by
'UK_HJWHE1QKYLIS421SH7BTMYPH1' defined on 'NMS_DAMPEN_CONFIG'.], SQL:
insert into NMS_DAMPEN_CONFIG
(UUID, VERSION, ENABLE, HR_INTERVAL, MIN_INTERVAL, PAYLOAD_FILTER, SEC_INTERVAL, ID)
values (?, ?, ?, ?, ?, ?, ?, ?)
(
https://hibernate.atlassian.net/browse/HHH-16502#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16502#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#100223- sha1:77dfe11 )