DM (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDY3NDM5YWZj...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16672?atlOrigin=eyJpIjoiZDY3ND...
) HHH-16672 (
https://hibernate.atlassian.net/browse/HHH-16672?atlOrigin=eyJpIjoiZDY3ND...
) Locking entities create in the same transaction fails (
https://hibernate.atlassian.net/browse/HHH-16672?atlOrigin=eyJpIjoiZDY3ND...
)
Issue Type: Bug Affects Versions: 5.6.15, 6.2.1 Assignee: Unassigned Created: 23/May/2023
01:08 AM Priority: Major Reporter: DM (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=712020%...
)
When creating and directly locking an entity, hibernate throws a
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction
(or unsaved-value mapping was incorrect) exception.
I guess, this is because the row does not exist yet in the table, so there is nothing to
lock. However, there is also no way for another transaction to access the new entity, so
it is already “locked” in a way. Thus, from my perspective, locking a freshly persisted
entity should do nothing.
I have made a test to reproduce this behavior:
https://github.com/mensinda/quarkus-stuff/tree/createAndLock (on the createAndLock
branch).
Additionally, the createAndLockeclipseLink branch contains the same test with eclipselink.
Interestingly, locking freshly created entities works here, with the exception of
find(..., LockModeType.PESSIMISTIC_WRITE.
(
https://hibernate.atlassian.net/browse/HHH-16672#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16672#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#100225- sha1:bbd69a1 )