use of example.entity.Emp in project doma by domaframework.
the class SelectBuilderTest method testGetResultList_Entity.
@Test
public void testGetResultList_Entity() {
SelectBuilder builder = SelectBuilder.newInstance(new MockConfig());
builder.sql("select * from Emp");
builder.sql("where");
builder.sql("aaa = ").param(String.class, "aaa");
builder.sql("and");
builder.sql("bbb = ").param(int.class, 100);
List<Emp> list = builder.getEntityResultList(Emp.class);
assertNotNull(list);
}
use of example.entity.Emp in project doma by domaframework.
the class BatchDeleteCommandTest method testExecute.
@Test
public void testExecute() throws Exception {
Emp emp1 = new Emp();
emp1.setId(1);
emp1.setName("hoge");
emp1.setVersion(10);
Emp emp2 = new Emp();
emp2.setId(2);
emp2.setName("foo");
emp2.setVersion(20);
AutoBatchDeleteQuery<Emp> query = new AutoBatchDeleteQuery<>(_Emp.getSingletonInternal());
query.setMethod(getClass().getDeclaredMethod(method.getName()));
query.setConfig(runtimeConfig);
query.setEntities(Arrays.asList(emp1, emp2));
query.setCallerClassName("aaa");
query.setCallerMethodName("bbb");
query.setSqlLogType(SqlLogType.FORMATTED);
query.prepare();
int[] rows = new BatchDeleteCommand(query).execute();
query.complete();
assertEquals(2, rows.length);
String sql = runtimeConfig.dataSource.connection.preparedStatement.sql;
assertEquals("delete from EMP where ID = ? and VERSION = ?", sql);
}
use of example.entity.Emp in project doma by domaframework.
the class EmpDaoImpl method delete.
@Override
public int delete(Emp entity) {
AutoDeleteQuery<Emp> query = __support.getQueryImplementors().createAutoDeleteQuery(method5, _Emp.getSingletonInternal());
query.setConfig(__support.getConfig());
query.setEntity(entity);
query.setCallerClassName("example.dao.EmpDao");
query.setCallerMethodName("delete");
query.prepare();
DeleteCommand command = __support.getCommandImplementors().createDeleteCommand(method5, query);
return command.execute();
}
use of example.entity.Emp in project doma by domaframework.
the class EmpDaoImpl method selectById.
@Override
public Emp selectById(Integer id, SelectOptions option) {
SqlFileSelectQuery query = __support.getQueryImplementors().createSqlFileSelectQuery(method0);
query.setConfig(__support.getConfig());
query.setSqlFilePath(SqlFileUtil.buildPath("example.dao.EmpDao", "selectById"));
query.addParameter("id", Integer.class, id);
query.setOptions(option);
query.setCallerClassName("example.dao.EmpDao");
query.setCallerMethodName("selectById");
query.prepare();
SelectCommand<Emp> command = __support.getCommandImplementors().createSelectCommand(method0, query, new EntitySingleResultHandler<Emp>(_Emp.getSingletonInternal()));
return command.execute();
}
use of example.entity.Emp in project doma by domaframework.
the class EmpDaoImpl method selectByNameAndSalary.
@Override
public List<Emp> selectByNameAndSalary(String name, BigDecimal salary, SelectOptions option) {
SqlFileSelectQuery query = __support.getQueryImplementors().createSqlFileSelectQuery(method1);
query.setConfig(__support.getConfig());
query.setSqlFilePath(SqlFileUtil.buildPath("example.dao.EmpDao", "selectByNameAndSalary"));
query.addParameter("name", String.class, name);
query.addParameter("salary", BigDecimal.class, salary);
query.setOptions(option);
query.setCallerClassName("example.dao.EmpDao");
query.setCallerMethodName("selectByNameAndSalary");
query.prepare();
SelectCommand<List<Emp>> command = __support.getCommandImplementors().createSelectCommand(method1, query, new EntityResultListHandler<Emp>(_Emp.getSingletonInternal()));
return command.execute();
}
Aggregations