Issues
- Hibernate increases version on readHHH-5867Resolved issue: HHH-5867Strong Liu
- Add setReadOnly(true) method to the Criteria interfaceHHH-3578Resolved issue: HHH-3578Former user
- Would like HQL support in criteria.OrderHHH-2987Resolved issue: HHH-2987
- Native SQLQuey combined with addEntity forces to retrieve all columnsHHH-2974Resolved issue: HHH-2974
- Incomplete/non-informative javadocs for events systemHHH-2958Resolved issue: HHH-2958Diego Plentz
- Hibernate Serializable classes do not declare serialVersionUIDHHH-2586Resolved issue: HHH-2586
- replicate() of non-versioned entiy can result in wrong value for version in entity cacheHHH-2378Resolved issue: HHH-2378Max Rydahl Andersen
- Wrong SQL generated for hql query on "any" relationHHH-1838Resolved issue: HHH-1838Steve Ebersole
- Event names for Configuration.setEventListener() should be fixed and documented.HHH-1801Resolved issue: HHH-1801
- org.hibernate.cfg.Configuration should obey standard java.util.Properties overwrite rulesHHH-1676Resolved issue: HHH-1676
- bulk delete causes RollbackExceptionHHH-1662Resolved issue: HHH-1662
- Collection cache not being populated correctlyHHH-1580Resolved issue: HHH-1580
- Hibernate fails after 1500 sessions on client Java5 JVMHHH-1579Resolved issue: HHH-1579Diego Plentz
- big misdesign in org.hibernate.cfg.Configuration breaks delegation Model of java.util.PropertiesHHH-1510Resolved issue: HHH-1510
14 of 14
Hibernate increases version on read
Rejected
Description
Attachments
1
Details
Assignee
Strong LiuStrong LiuReporter
ChristianChristianComponents
Affects versions
Priority
Critical
Details
Details
Assignee
Strong Liu
Strong LiuReporter
Christian
ChristianComponents
Affects versions
Priority
Created January 25, 2011 at 8:43 AM
Updated March 7, 2014 at 5:31 PM
Resolved May 20, 2011 at 7:30 AM
Activity
Show:
Brett MeyerMarch 7, 2014 at 5:31 PM
Bulk closing rejected tickets in "resolved" state.
Strong LiuMay 20, 2011 at 7:30 AM
it is not a bug, this is caused by your own custom type impl.
hibernate use equals to check if a property is changed (aka dirty).
in your test, the MyComponent#type is null, and with your ShortEnumUserType#equals, it returns false if the type is null,
so, you actually tell hibernate if the type is null, then the managed entity is dirty, that's why hibernate schedule a update.
add
On a special constellation hibernate increases the internal used version of an entity on a read operation. For example if you save an entity the version is initial set. If you execute a query to read the entity afterwards, the version increases on this read. Please notice that the entity has NOT changed in the meantime. An update of the version must not happen here.
This problem seems to occur only if you have a few prequisites:
1. An entity, which has a component or subclasses
2. The component/subclasses must use an custom usertype
3. The read operation is covered by transaction
The bug leads to StaleObjectStateExceptions in production because the version has changed after a read operation by another thread.
An example is attached.