OPTIMISTIC_FORCE_INCREMENT is not incrementing version field of non-dirty entities
----------------------------------------------------------------------------------
Key: JPA-14
URL:
http://opensource.atlassian.com/projects/hibernate/browse/JPA-14
Project: Java Persistence API
Issue Type: Bug
Environment: MySQL 5.1.53 with InnoDB, Hibernate 3.1.6 Final, Java 1.6.0_22
Reporter: Behrang Saeedzadeh
According to the JPA 2 spec:
{quote}
If transaction T1 calls {{lock(entity, LockModeType.OPTIMISTIC_FORCE_INCREMENT)}} on a
versioned object, the entity manager must avoid the phenomena P1 and P2 (as with
{{LockModeType.OPTIMISTIC}}) and must also force an update (increment) to the entity's
version column. A forced version update may be performed immediately, or may be deferred
until a flush or commit. If an entity is removed before a deferred version update was to
have been applied, the forced version update
is omitted.
{quote}
However, Hibernate is not incrementing the version field when the entity is not altered in
the transaction:
{code}
final EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
VersionedEntity entity = em.find(VersionedEntity.class, id);
em.lock(entity, LockModeType.PESSIMISTIC_FORCE_INCREMENT);
em.getTransaction().commit();
em.close();
{code}
However, the spec says ??must also force an update (increment) to the entity's version
column?? and does not give the option to ignore updating the version number if the entity
was not dirty.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira