Hibernate increases version on read

Description

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.

Environment

Affects latest Hibernate version(3.6 and before). Tested with Db2 and MSSQL Server 2007.

Attachments

Assignee

Strong Liu

Reporter

Christian

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Critical
Configure