]
Strong Liu resolved HHH-5867.
-----------------------------
Assignee: Strong Liu
Resolution: Rejected
Fix Version/s: (was: 3.6.5)
(was: 4.0.0.Beta1)
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.
{code}
@Override
public boolean equals(final Object x, final Object y) {
if ( x == null || y == null ) {
return false;
}
return x.equals( y );
}
{code}
add
{code}
if(x==y)return true;
{code}
Hibernate increases version on read
-----------------------------------
Key: HHH-5867
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5867
Project: Hibernate Core
Issue Type: Bug
Components: core, entity-manager
Affects Versions: 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2, 3.1 rc3, 3.1, 3.1.1,
3.1.2, 3.2.0.alpha1, 3.2.0.alpha2, 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3, 3.2.0.cr4,
3.2.0.cr5, 3.2.0.ga, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.4.sp1, 3.2.5, 3.2.6, 3.2.7,
3.3.0.CR1, 3.3.0.CR2, 3.3.0.GA, 3.3.0.SP1, 3.3.1, 3.3.2, 3.5.0.Beta-1, 3.5.0-Beta-2,
3.5.0-Beta-3, 3.5.0-Beta-4, 3.5.0-CR-1, 3.5.0-CR-2, 3.5.0-Final, 3.5.1, 3.5.2, 3.5.3,
3.5.4, 3.6.0.Beta1, 3.6.0.Beta2, 3.5.5, 3.6.0.Beta3, 3.6.0.Beta4, 3.5.6, 3.6.0.CR1,
3.6.0.CR2, 3.6.0
Environment: Affects latest Hibernate version(3.6 and before). Tested with Db2
and MSSQL Server 2007.
Reporter: Christian
Assignee: Strong Liu
Priority: Critical
Attachments: TestHibernateVersionBug.zip
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.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: