[hibernate-issues] [JIRA] (HHH-13867) StaleObjectStateException into a SINGLE transaction for entity with version field of type java.util.Date

Глеб Егунов (JIRA) jira at hibernate.atlassian.net
Fri Feb 14 11:31:32 EST 2020


Глеб Егунов ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A04f4cf2c-b20f-48c6-b9b6-825a59b1e499 ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjM1NWY3ZjI5MzIxNGNjODk1Y2E0YmFkM2YyMjY0MmUiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13867?atlOrigin=eyJpIjoiZjM1NWY3ZjI5MzIxNGNjODk1Y2E0YmFkM2YyMjY0MmUiLCJwIjoiaiJ9 ) HHH-13867 ( https://hibernate.atlassian.net/browse/HHH-13867?atlOrigin=eyJpIjoiZjM1NWY3ZjI5MzIxNGNjODk1Y2E0YmFkM2YyMjY0MmUiLCJwIjoiaiJ9 ) StaleObjectStateException into a SINGLE transaction for entity with version field of type java.util.Date ( https://hibernate.atlassian.net/browse/HHH-13867?atlOrigin=eyJpIjoiZjM1NWY3ZjI5MzIxNGNjODk1Y2E0YmFkM2YyMjY0MmUiLCJwIjoiaiJ9 )

Issue Type: Bug Assignee: Unassigned Created: 14/Feb/2020 08:31 AM Priority: Major Reporter: Глеб Егунов ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A04f4cf2c-b20f-48c6-b9b6-825a59b1e499 )

He team! We got stuck with the following issue: StaleObjectStateException arises during the update execution into the SINGLE transaction.

Feel free to look at the code on *bitbucket* :
https://bitbucket.org/gegunov/hibernate_issue/src/master/
*README* with examples are also attached there.

Steps to reproduce:

*prerequisites* :

* Table DDL
CREATE TABLE `payment` (
 `id` int (11) NOT NULL AUTO_INCREMENT,
 `status` varchar(45) DEFAULT NULL,
 `last_update_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY (`id`),
 UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1

* Entity class with fields: 1) of type *java.util.Date* annotated by *@Version* e.g *lastUpdateDate*
2) of type java.util.String for *state*
3) of type Long (for *Id* )

* Create entity having any state.
* Then in the other transaction execute the following steps: * *find* the created entity with entityManager.find
* *update* the field state (of type String)
* execute another one *select* from database using entityManager. It doesn't matter what it will return. It could even return *nothing*. In the provided code I deliberately use keys which not exist in DB
* *update* the entity again with different value.

* When the transaction is being committed it will fail with the following error
*org.hibernate.StaleObjectStateException* : Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

It should be said that the mentioned behavior is not reproduced with the version field of type *short* , only with *java.util.Date*

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

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#100120- sha1:2415f4c )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200214/e99f0ffb/attachment.html 


More information about the hibernate-issues mailing list