use of com.ctrip.platform.dal.dao.helper.DalDefaultJpaParser in project dal by ctripcorp.
the class BatchUpdateTaskTestStub method testIncludeExcludeColumns.
@Test
public void testIncludeExcludeColumns() throws SQLException {
BatchUpdateTask<UpdatableIntVersionModel> test = new BatchUpdateTask<>();
DalParser<UpdatableIntVersionModel> parser = new DalDefaultJpaParser<>(UpdatableIntVersionModel.class, getDbName());
test.initialize(parser);
DalTableDao<UpdatableIntVersionModel> dao = new DalTableDao<>(parser);
DalHints hints = new DalHints().exclude("dbIndex").include("quantity", "dbIndex", "address");
List<UpdatableIntVersionModel> pojos = dao.query("1=1", new StatementParameters(), new DalHints());
for (UpdatableIntVersionModel model : pojos) {
model.setQuantity(500);
model.setDbIndex(100);
model.setAddress("1122334455");
}
int[] result = execute(test, hints, pojos);
assertArrayEquals(new int[] { 1, 1, 1 }, result);
pojos = dao.query("1=1", new StatementParameters(), new DalHints());
for (UpdatableIntVersionModel model : pojos) {
assertEquals("1122334455", model.getAddress());
assertEquals(500, model.getQuantity().intValue());
assertEquals(0, model.getDbIndex().intValue());
}
}
use of com.ctrip.platform.dal.dao.helper.DalDefaultJpaParser in project dal by ctripcorp.
the class SingleInsertTaskTestStub method testExecuteWithNonInsertable.
@Test
public void testExecuteWithNonInsertable() throws SQLException {
SingleInsertTask<NonInsertableVersionModel> test = new SingleInsertTask<>();
DalParser<NonInsertableVersionModel> parser = new DalDefaultJpaParser<>(NonInsertableVersionModel.class, getDbName());
test.initialize(parser);
DalHints hints = new DalHints();
int result = test.execute(hints, getAllMap().get(0), null);
assertEquals(3 + 1, getCount());
Map<Integer, Map<String, ?>> pojos = getAllMap();
for (Map<String, ?> pojo : pojos.values()) {
assertNotNull(pojo.get("last_changed"));
}
}
Aggregations