[hibernate-issues] [JIRA] (HHH-14054) Hibernate insert/update ordering wrt unique constraints

Koen Serneels (JIRA) jira at hibernate.atlassian.net
Tue Jun 2 03:07:12 EDT 2020


Koen Serneels ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A956c77bd-dde9-4e6d-aafd-30082b747b74 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjE4NGM0YTQ2ZDFkNDU1ZWI3MGQzNWVhMTM5OTIxNmMiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14054?atlOrigin=eyJpIjoiNjE4NGM0YTQ2ZDFkNDU1ZWI3MGQzNWVhMTM5OTIxNmMiLCJwIjoiaiJ9 ) HHH-14054 ( https://hibernate.atlassian.net/browse/HHH-14054?atlOrigin=eyJpIjoiNjE4NGM0YTQ2ZDFkNDU1ZWI3MGQzNWVhMTM5OTIxNmMiLCJwIjoiaiJ9 ) Hibernate insert/update ordering wrt unique constraints ( https://hibernate.atlassian.net/browse/HHH-14054?atlOrigin=eyJpIjoiNjE4NGM0YTQ2ZDFkNDU1ZWI3MGQzNWVhMTM5OTIxNmMiLCJwIjoiaiJ9 )

Change By: Koen Serneels ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A956c77bd-dde9-4e6d-aafd-30082b747b74 )

Hi. In the example created for this issue (please see: [https://github.com/koen-serneels/hibernate-uc-violation|https://github.com/koen-serneels/hibernate-uc-violation]) is an entity with a single property ‘value’ and unique constraint. Initially there is an existing instance with it’s property ‘value’ equal to ‘val1’. When we now do following within the same transaction:

* change the value on the existing entity from “val1” to “val2”
* add a new entity with “val1”

We get a ConstraintViolationException because Hibernate is executing the insert before the update. Now, is this actually expected knowing that Hibernate knows about the unique constraint and that it would make more sense to perform the insert after the update or is this a bug?

Btw; I posted this first on the forum ([https://discourse.hibernate.org/t/hibernate-insert-update-ordering-wrt-unique-constraints/4201|https://discourse.hibernate.org/t/hibernate-insert-update-ordering-wrt-unique-constraints/4201] ) , but in absence of any response I started thinking this might be a bug/feature. Thanks\!

( https://hibernate.atlassian.net/browse/HHH-14054#add-comment?atlOrigin=eyJpIjoiNjE4NGM0YTQ2ZDFkNDU1ZWI3MGQzNWVhMTM5OTIxNmMiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14054#add-comment?atlOrigin=eyJpIjoiNjE4NGM0YTQ2ZDFkNDU1ZWI3MGQzNWVhMTM5OTIxNmMiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100127- sha1:2783216 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200602/68baf71d/attachment.html 


More information about the hibernate-issues mailing list