Search in sources :

Example 1 with ShortRowMapper

use of com.ctrip.platform.dal.dao.helper.ShortRowMapper 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"));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) ShortRowMapper(com.ctrip.platform.dal.dao.helper.ShortRowMapper) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ShortRowMapper

use of com.ctrip.platform.dal.dao.helper.ShortRowMapper 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());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ShortRowMapper(com.ctrip.platform.dal.dao.helper.ShortRowMapper) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) ArrayList(java.util.ArrayList)

Example 3 with ShortRowMapper

use of com.ctrip.platform.dal.dao.helper.ShortRowMapper in project dal by ctripcorp.

the class DalQueryDaoTest method queryListForInParamBuilderNew1.

// Test in parameters
private List<Short> queryListForInParamBuilderNew1(DalHints hints) throws SQLException {
    StatementParameters parameters = new StatementParameters();
    FreeSelectSqlBuilder<List<Short>> builder = new FreeSelectSqlBuilder<>();
    builder.with(parameters);
    List<Integer> inParam = new ArrayList<>();
    inParam.add(0);
    inParam.add(1);
    inParam.add(2);
    inParam.add(3);
    inParam.add(4);
    builder.selectAll().from(TABLE_NAME).where(in("type", inParam, Types.INTEGER));
    builder.mapWith(new ShortRowMapper());
    return dao.query(builder, parameters, hints.shardBy("type"));
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ShortRowMapper(com.ctrip.platform.dal.dao.helper.ShortRowMapper) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with ShortRowMapper

use of com.ctrip.platform.dal.dao.helper.ShortRowMapper in project dal by ctripcorp.

the class DalQueryDaoTest method queryListForInParamBuilderNew.

// Test in parameters
private List<Short> queryListForInParamBuilderNew(DalHints hints) throws SQLException {
    StatementParameters parameters = new StatementParameters();
    FreeSelectSqlBuilder<List<Short>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.with(parameters);
    List<Integer> inParam = new ArrayList<>();
    inParam.add(0);
    inParam.add(1);
    inParam.add(2);
    inParam.add(3);
    inParam.add(4);
    builder.setIn("type", inParam, Types.INTEGER);
    builder.setTemplate(sqlInParam);
    builder.mapWith(new ShortRowMapper());
    return dao.query(builder, parameters, hints.shardBy("type"));
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ShortRowMapper(com.ctrip.platform.dal.dao.helper.ShortRowMapper) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ShortRowMapper

use of com.ctrip.platform.dal.dao.helper.ShortRowMapper 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());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ShortRowMapper(com.ctrip.platform.dal.dao.helper.ShortRowMapper) ArrayList(java.util.ArrayList)

Aggregations

ShortRowMapper (com.ctrip.platform.dal.dao.helper.ShortRowMapper)8 ArrayList (java.util.ArrayList)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)6 List (java.util.List)6 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)4