[hibernate-issues] [JIRA] (HHH-14054) Hibernate insert/update ordering wrt unique constraints
Koen Serneels (JIRA)
jira at hibernate.atlassian.net
Tue Jun 2 03:06:48 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=eyJpIjoiNDliZTJmNGE5YTQ5NDMzNWIzZjg4ZGQxZjU5OWM3MTUiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14054?atlOrigin=eyJpIjoiNDliZTJmNGE5YTQ5NDMzNWIzZjg4ZGQxZjU5OWM3MTUiLCJwIjoiaiJ9 ) HHH-14054 ( https://hibernate.atlassian.net/browse/HHH-14054?atlOrigin=eyJpIjoiNDliZTJmNGE5YTQ5NDMzNWIzZjg4ZGQxZjU5OWM3MTUiLCJwIjoiaiJ9 ) Hibernate insert/update ordering wrt unique constraints ( https://hibernate.atlassian.net/browse/HHH-14054?atlOrigin=eyJpIjoiNDliZTJmNGE5YTQ5NDMzNWIzZjg4ZGQxZjU5OWM3MTUiLCJwIjoiaiJ9 )
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 , 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 ?
* Is there a more elegant way to deal with or is this than performing manual flushes as illustrated by the test
case 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=eyJpIjoiNDliZTJmNGE5YTQ5NDMzNWIzZjg4ZGQxZjU5OWM3MTUiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14054#add-comment?atlOrigin=eyJpIjoiNDliZTJmNGE5YTQ5NDMzNWIzZjg4ZGQxZjU5OWM3MTUiLCJwIjoiaiJ9 )
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:6728f9f )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200602/e368f3ca/attachment.html
More information about the hibernate-issues
mailing list