[hibernate-commits] Hibernate SVN: r11526 - in branches/Branch_3_2/Hibernate3: test/org/hibernate/test/jpa/lock and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue May 15 16:15:58 EDT 2007


Author: epbernard
Date: 2007-05-15 16:15:58 -0400 (Tue, 15 May 2007)
New Revision: 11526

Modified:
   branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java
Log:
HHH-2613 support LockMode.FORCE on non-versioned entity

Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java	2007-05-14 21:51:58 UTC (rev 11525)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/persister/entity/AbstractEntityPersister.java	2007-05-15 20:15:58 UTC (rev 11526)
@@ -1314,7 +1314,7 @@
 		lockers.put( LockMode.READ, generateLocker( LockMode.READ ) );
 		lockers.put( LockMode.UPGRADE, generateLocker( LockMode.UPGRADE ) );
 		lockers.put( LockMode.UPGRADE_NOWAIT, generateLocker( LockMode.UPGRADE_NOWAIT ) );
-		//lockers.put( LockMode.FORCE, generateLocker( LockMode.FORCE ) );
+		lockers.put( LockMode.FORCE, generateLocker( LockMode.FORCE ) );
 	}
 
 	protected LockingStrategy generateLocker(LockMode lockMode) {

Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java	2007-05-14 21:51:58 UTC (rev 11525)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/jpa/lock/JPALockTest.java	2007-05-15 20:15:58 UTC (rev 11526)
@@ -8,6 +8,7 @@
 import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
 import org.hibernate.test.jpa.AbstractJPATest;
 import org.hibernate.test.jpa.Item;
+import org.hibernate.test.jpa.MyEntity;
 
 /**
  * Tests specifically relating to section 3.3.5.3 [Lock Modes] of the
@@ -139,6 +140,9 @@
 		Item item = new Item();
 		item.setName( initialName );
 		s1.save( item );
+		MyEntity myEntity = new MyEntity();
+		myEntity.setName( "Test" );
+		s1.save( myEntity );
 		t1.commit();
 		s1.close();
 
@@ -151,6 +155,11 @@
 		s1.lock( item, LockMode.FORCE );
 		assertEquals( "no forced version increment", initialVersion + 1, item.getVersion() );
 
+		myEntity = (MyEntity) s1.get( MyEntity.class, myEntity.getId() );
+		s1.lock( myEntity, LockMode.FORCE );
+		assertTrue( "LockMode.FORCE on a unversioned entity should degrade nicely to UPGRADE", true );
+
+
 		s1.lock( item, LockMode.FORCE );
 		assertEquals( "subsequent LockMode.FORCE did not no-op", initialVersion + 1, item.getVersion() );
 
@@ -183,6 +192,7 @@
 		s1 = getSessions().openSession();
 		t1 = s1.beginTransaction();
 		s1.delete( item );
+		s1.delete( myEntity );
 		t1.commit();
 		s1.close();
 	}




More information about the hibernate-commits mailing list