Fix test failure

This commit is contained in:
Steve Ebersole 2022-03-08 23:24:00 -06:00
parent 92686b16e2
commit 3a6ad2fd3a
2 changed files with 2 additions and 13 deletions

View File

@ -149,10 +149,8 @@ public enum LockMode {
}
}
for ( LockMode lockMode : LockMode.values() ) {
if ( lockMode.externalForm.equalsIgnoreCase( externalForm ) ) {
return lockMode;
}
if ( externalForm.equalsIgnoreCase( "upgrade" ) ) {
return PESSIMISTIC_WRITE;
}
throw new IllegalArgumentException( "Unable to interpret LockMode reference from incoming external form : " + externalForm );

View File

@ -183,13 +183,10 @@ public class JPALockTest extends AbstractJPATest {
final String initialName = "lock test";
// set up some test data
Item it = new Item();
MyEntity entity = new MyEntity();
inTransaction(
session -> {
it.setName( initialName );
session.save( it );
entity.setName( "Test" );
session.save( entity );
}
);
@ -197,7 +194,6 @@ public class JPALockTest extends AbstractJPATest {
long initialVersion = it.getVersion();
Session s1 = null;
Session s2 = null;
MyEntity myEntity;
Item item;
try {
s1 = sessionFactory().openSession();
@ -206,10 +202,6 @@ public class JPALockTest extends AbstractJPATest {
s1.lock( item, LockMode.PESSIMISTIC_FORCE_INCREMENT );
assertEquals( initialVersion + 1, item.getVersion(), "no forced version increment" );
myEntity = s1.get( MyEntity.class, entity.getId() );
s1.lock( myEntity, LockMode.PESSIMISTIC_FORCE_INCREMENT );
assertTrue( true, "LockMode.PESSIMISTIC_FORCE_INCREMENT on a un-versioned entity should degrade nicely to UPGRADE" );
s1.lock( item, LockMode.PESSIMISTIC_FORCE_INCREMENT );
assertEquals( initialVersion + 1, item.getVersion(), "subsequent LockMode.FORCE did not no-op" );
@ -275,7 +267,6 @@ public class JPALockTest extends AbstractJPATest {
inTransaction(
session -> {
session.delete( item );
session.delete( myEntity );
}
);
}