]
Rodrigo Carvalho Rezende updated JPA-14:
----------------------------------------
Attachment: hibernate-optimistic-force-increment.tar.gz
Here you have an Eclipse project with a test case for this issue.
Hibernate-core 3.6.10
Mysql + JDBC connector 5.1.18
OPTIMISTIC_FORCE_INCREMENT is not incrementing version field of
non-dirty entities
----------------------------------------------------------------------------------
Key: JPA-14
URL:
https://hibernate.onjira.com/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
Attachments: hibernate-optimistic-force-increment.tar.gz
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.
For more information on JIRA, see: