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) {
}
}
use of com.ctrip.platform.dal.dao.StatementParameters in project dal by ctripcorp.
the class DalQueryDaoTest method queryListForInParamOld.
// Test in parameters
private List<Short> queryListForInParamOld(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);
String sql = SQLParser.parse(sqlInParam, inParam);
return dao.query(sql, parameters, hints.inAllShards(), new ShortRowMapper());
}
Aggregations