Search in sources :

Example 1 with MultipleSqlBuilder

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

Aggregations

StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)1 MultipleSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.MultipleSqlBuilder)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1