Fix test failure
This commit is contained in:
parent
92686b16e2
commit
3a6ad2fd3a
|
@ -149,10 +149,8 @@ public enum LockMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( LockMode lockMode : LockMode.values() ) {
|
if ( externalForm.equalsIgnoreCase( "upgrade" ) ) {
|
||||||
if ( lockMode.externalForm.equalsIgnoreCase( externalForm ) ) {
|
return PESSIMISTIC_WRITE;
|
||||||
return lockMode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException( "Unable to interpret LockMode reference from incoming external form : " + externalForm );
|
throw new IllegalArgumentException( "Unable to interpret LockMode reference from incoming external form : " + externalForm );
|
||||||
|
|
|
@ -183,13 +183,10 @@ public class JPALockTest extends AbstractJPATest {
|
||||||
final String initialName = "lock test";
|
final String initialName = "lock test";
|
||||||
// set up some test data
|
// set up some test data
|
||||||
Item it = new Item();
|
Item it = new Item();
|
||||||
MyEntity entity = new MyEntity();
|
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
it.setName( initialName );
|
it.setName( initialName );
|
||||||
session.save( it );
|
session.save( it );
|
||||||
entity.setName( "Test" );
|
|
||||||
session.save( entity );
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -197,7 +194,6 @@ public class JPALockTest extends AbstractJPATest {
|
||||||
long initialVersion = it.getVersion();
|
long initialVersion = it.getVersion();
|
||||||
Session s1 = null;
|
Session s1 = null;
|
||||||
Session s2 = null;
|
Session s2 = null;
|
||||||
MyEntity myEntity;
|
|
||||||
Item item;
|
Item item;
|
||||||
try {
|
try {
|
||||||
s1 = sessionFactory().openSession();
|
s1 = sessionFactory().openSession();
|
||||||
|
@ -206,10 +202,6 @@ public class JPALockTest extends AbstractJPATest {
|
||||||
s1.lock( item, LockMode.PESSIMISTIC_FORCE_INCREMENT );
|
s1.lock( item, LockMode.PESSIMISTIC_FORCE_INCREMENT );
|
||||||
assertEquals( initialVersion + 1, item.getVersion(), "no forced version 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 );
|
s1.lock( item, LockMode.PESSIMISTIC_FORCE_INCREMENT );
|
||||||
assertEquals( initialVersion + 1, item.getVersion(), "subsequent LockMode.FORCE did not no-op" );
|
assertEquals( initialVersion + 1, item.getVersion(), "subsequent LockMode.FORCE did not no-op" );
|
||||||
|
|
||||||
|
@ -275,7 +267,6 @@ public class JPALockTest extends AbstractJPATest {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.delete( item );
|
session.delete( item );
|
||||||
session.delete( myEntity );
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue