use of org.apache.cayenne.testdo.locking.RelLockingTestEntity in project cayenne by apache.
the class OptimisticLockingIT method testFailLockingOnToOne.
@Test
public void testFailLockingOnToOne() throws Exception {
createLockingOnToOneDataSet();
List<RelLockingTestEntity> allObjects = new SelectQuery<>(RelLockingTestEntity.class).select(context);
assertEquals(1, allObjects.size());
RelLockingTestEntity object = allObjects.get(0);
// change name and save... no optimistic lock failure expected
object.setName("first update");
context.commitChanges();
// change relationship and save... no optimistic lock failure expected
SimpleLockingTestEntity object1 = context.newObject(SimpleLockingTestEntity.class);
object.setToSimpleLockingTest(object1);
context.commitChanges();
// change row underneath, change description and save... optimistic lock failure
// expected
createRelLockUpdate();
object.setName("third update");
try {
context.commitChanges();
fail("Optimistic lock failure expected.");
} catch (OptimisticLockException ex) {
// optimistic lock failure expected...
}
}
Aggregations