use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class MapBatchInsertBuilderTest method testNotEqualMapSize.
@SuppressWarnings("serial")
@Test
public void testNotEqualMapSize() {
MapBatchInsertBuilder builder = MapBatchInsertBuilder.newInstance(new MockConfig(), "Emp");
List<LinkedHashMap<String, Object>> employees = new ArrayList<LinkedHashMap<String, Object>>() {
{
add(new LinkedHashMap<String, Object>() {
{
put("name", "SMITH");
}
});
add(new LinkedHashMap<String, Object>() {
{
put("name", "ALLEN");
put("salary", 2000);
}
});
}
};
try {
builder.execute(employees);
} catch (JdbcException e) {
assertEquals(Message.DOMA2231, e.getMessageResource());
return;
}
fail();
}
use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class BatchDeleteExecutorTest method testChangeType.
@Test
public void testChangeType() {
SqlBatchDeleteQuery query = mockQuery();
BatchBuilder builder = BatchBuilder.newInstance(query);
builder.sql("delete from Emp");
builder.sql("where");
builder.sql("name = ").param(String.class, "SMITH");
builder.sql("and");
builder.sql("salary = ").param(BigDecimal.class, new BigDecimal("1000"));
builder = builder.fixSql();
builder.sql("delete from Emp");
builder.sql("where");
builder.sql("name = ").param(String.class, "ALLEN");
builder.sql("and");
builder = builder.sql("salary = ");
try {
builder.param(int.class, 2000);
} catch (JdbcException e) {
assertEquals(Message.DOMA2229, e.getMessageResource());
return;
}
fail();
}
use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class AutoInsertTest method testIdNotAssigned.
@Test
public void testIdNotAssigned(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = new Department();
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
try {
dao.insert(department);
fail();
} catch (JdbcException expected) {
assertEquals(Message.DOMA2020, expected.getMessageResource());
}
}
use of org.seasar.doma.jdbc.JdbcException in project doma by domaframework.
the class AutoBatchDeleteTest method testNoId.
@Test
public void testNoId(Config config) throws Exception {
NoIdDao dao = new NoIdDaoImpl(config);
NoId entity = new NoId();
entity.setValue1(1);
entity.setValue2(2);
NoId entity2 = new NoId();
entity2.setValue1(1);
entity2.setValue2(2);
try {
dao.delete(Arrays.asList(entity, entity2));
fail();
} catch (JdbcException expected) {
assertEquals(Message.DOMA2022, expected.getMessageResource());
}
}
Aggregations