use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DalQueryDaoTest method queryMultipleAllShards.
private List queryMultipleAllShards(DalHints hints) throws SQLException {
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.INTEGER, 1);
MultipleSqlBuilder builder = new MultipleSqlBuilder();
// TODO add all add method
//mapper
builder.addQuery(sqlList, new StatementParameters(), new ClientTestDalRowMapper());
//merger
builder.addQuery(sqlList, new StatementParameters(), new ClientTestDalRowMapper(), new DalListMerger<ClientTestModel>());
//sorter
builder.addQuery(sqlList, new StatementParameters(), ClientTestModel.class, new ClientTestModelComparator());
//merger
builder.addQuery(sqlListQuantity, new StatementParameters(), Integer.class, new DalListMerger<Integer>());
//soter
builder.addQuery(sqlObject, parameters, Integer.class, new InteregrComparator());
//callback
builder.addQuery(sqlNoResult, new StatementParameters(), new TestDalRowCallback3());
parameters = new StatementParameters();
List<Integer> inParam = new ArrayList<>();
inParam.add(0);
inParam.add(1);
inParam.add(2);
inParam.add(3);
inParam.add(4);
parameters.setInParameter(1, "type", Types.INTEGER, inParam);
builder.addQuery(sqlIdInParam, parameters, ClientTestModel.class);
return dao.query(builder, hints.inAllShards());
}
use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DalQueryDaoTest method testQueryFirstAllShardsFail.
@Test
public void testQueryFirstAllShardsFail() {
try {
DalHints hints = new DalHints();
StatementParameters parameters = new StatementParameters();
parameters.set(1, 1);
ClientTestModel result = dao.queryFirst(sqlNoResult, parameters(), hints.inAllShards(), new ClientTestDalRowMapper());
fail();
} catch (Exception e) {
}
}
use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DalQueryDaoTest method testQueryFirstAllShardsWithClassNullable.
@Test
public void testQueryFirstAllShardsWithClassNullable() {
try {
DalHints hints = new DalHints();
StatementParameters parameters = new StatementParameters();
Integer result = dao.queryFirstNullable(sqlNoResult, parameters, hints.inAllShards(), Integer.class);
assertNull(result);
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DalQueryDaoTest method queryListForInParamBuilder.
// Test in parameters
private List<Short> queryListForInParamBuilder(DalHints hints) throws SQLException {
StatementParameters parameters = new StatementParameters();
List<Integer> inParam = new ArrayList<>();
inParam.add(0);
inParam.add(1);
inParam.add(2);
inParam.add(3);
inParam.add(4);
parameters.setInParameter(1, "type", Types.INTEGER, inParam);
FreeSelectSqlBuilder<List<Short>> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate(sqlInParam);
builder.mapWith(new ShortRowMapper());
return dao.query(builder, parameters, hints.shardBy("type"));
}
use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DalQueryDaoTest method testQueryForObjectAllShardsFailPartial.
@Test
public void testQueryForObjectAllShardsFailPartial() {
try {
DalHints hints = new DalHints();
StatementParameters parameters = new StatementParameters();
parameters.set(1, 1);
ClientTestModel result = dao.queryForObject(sqlFirst, parameters, hints.inAllShards().partialQuery("quantity", "address"), new ClientTestDalRowMapper());
fail();
} catch (Exception e) {
}
}
Aggregations