use of org.seasar.doma.jdbc.OptimisticLockException in project doma by domaframework.
the class DeleteCommandTest method testExecute_throwsOptimisticLockException.
@Test
public void testExecute_throwsOptimisticLockException() {
Emp emp = new Emp();
emp.setId(10);
emp.setName("aaa");
emp.setVersion(100);
MockPreparedStatement ps = new MockPreparedStatement();
ps.updatedRows = 0;
runtimeConfig.dataSource.connection = new MockConnection(ps);
AutoDeleteQuery<Emp> query = new AutoDeleteQuery<>(_Emp.getSingletonInternal());
query.setMethod(method);
query.setConfig(runtimeConfig);
query.setEntity(emp);
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
DeleteCommand command = new DeleteCommand(query);
try {
command.execute();
fail();
} catch (OptimisticLockException expected) {
}
}
use of org.seasar.doma.jdbc.OptimisticLockException in project doma by domaframework.
the class AutoBatchUpdateTest method testTenantId.
@Test
public void testTenantId(Config config) throws Exception {
SalesmanDao dao = new SalesmanDaoImpl(config);
Salesman salesman = dao.selectById(1);
Integer tenantId = salesman.departmentId;
salesman.departmentId = -1;
try {
dao.update(Arrays.asList(salesman));
fail();
} catch (OptimisticLockException expected) {
}
salesman.departmentId = tenantId;
dao.update(Arrays.asList(salesman));
}
use of org.seasar.doma.jdbc.OptimisticLockException in project doma by domaframework.
the class AutoDeleteTest method testTenantId.
@Test
public void testTenantId(Config config) throws Exception {
SalesmanDao dao = new SalesmanDaoImpl(config);
Salesman salesman = dao.selectById(1);
Integer tenantId = salesman.departmentId;
salesman.departmentId = -1;
try {
dao.delete(salesman);
fail();
} catch (OptimisticLockException expected) {
}
salesman.departmentId = tenantId;
dao.delete(salesman);
}
Aggregations