Author: smarlow(a)redhat.com
Date: 2010-04-26 13:49:26 -0400 (Mon, 26 Apr 2010)
New Revision: 19295
Modified:
core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java
Log:
HHH-5032 upgrade from optimistic to optimistic force does not work
Modified:
core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2010-04-26
16:21:26 UTC (rev 19294)
+++
core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2010-04-26
17:49:26 UTC (rev 19295)
@@ -3225,8 +3225,8 @@
readLoader :
createEntityLoader( LockMode.PESSIMISTIC_FORCE_INCREMENT )
);
- loaders.put( LockMode.OPTIMISTIC, readLoader );
- loaders.put( LockMode.OPTIMISTIC_FORCE_INCREMENT, readLoader );
+ loaders.put( LockMode.OPTIMISTIC, createEntityLoader( LockMode.OPTIMISTIC) );
+ loaders.put( LockMode.OPTIMISTIC_FORCE_INCREMENT,
createEntityLoader(LockMode.OPTIMISTIC_FORCE_INCREMENT) );
loaders.put(
"merge",
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java 2010-04-26
16:21:26 UTC (rev 19294)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java 2010-04-26
17:49:26 UTC (rev 19295)
@@ -210,6 +210,28 @@
em.close();
}
+ public void testLockOptimisticForceIncrementDifferentEm() throws Exception {
+ Lock lock = new Lock();
+ lock.setName( "force" );
+ EntityManager em1 = createIsolatedEntityManager();
+ em1.getTransaction().begin();
+ em1.persist( lock );
+ em1.getTransaction().commit();
+ em1.close();
+
+ EntityManager em2 = createIsolatedEntityManager();
+ em2.getTransaction().begin();
+ lock = em2.find( Lock.class, lock.getId(), LockModeType.OPTIMISTIC );
+ assertEquals( "lock mode should be OPTIMISTIC ", LockModeType.OPTIMISTIC,
em2.getLockMode(lock) );
+ em2.lock( lock, LockModeType.OPTIMISTIC_FORCE_INCREMENT );
+ assertEquals( "lock mode should be OPTIMISTIC_FORCE_INCREMENT ",
LockModeType.OPTIMISTIC_FORCE_INCREMENT, em2.getLockMode(lock) );
+ em2.getTransaction().commit();
+ em2.getTransaction().begin();
+ em2.remove( lock );
+ em2.getTransaction().commit();
+ em2.close();
+ }
+
public void testContendedPessimisticLock() throws Exception {
EntityManager em = getOrCreateEntityManager();
Show replies by date