use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class BaseDalTabelDaoShardByTableTest method testQueryListBySimpleTypeInTableShards.
@Test
public void testQueryListBySimpleTypeInTableShards() throws SQLException {
Set<String> tableShards = new HashSet<>();
tableShards.add("0");
// expected 1 record
SelectSqlBuilder ssb1 = new SelectSqlBuilder();
ssb1.selectAll().from(TABLE_NAME).where(" id = 1 ");
List<Integer> list1 = dao.query(ssb1, new DalHints().inTableShards(tableShards), Integer.class);
assertEquals(1, list1.size());
// expected 2 records
tableShards.add("1");
List<Integer> list2 = dao.query(ssb1, new DalHints().inTableShards(tableShards), Integer.class);
assertEquals(2, list2.size());
// expected 3 records
tableShards.add("2");
List<Integer> list3 = dao.query(ssb1, new DalHints().inTableShards(tableShards), Integer.class);
assertEquals(3, list3.size());
// expected 4 records
tableShards.add("3");
List<Integer> list4 = dao.query(ssb1, new DalHints().inTableShards(tableShards), Integer.class);
assertEquals(4, list4.size());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class BaseDalTabelDaoShardByTableTest method testCountTableShardBy2.
@Test
public void testCountTableShardBy2() throws SQLException {
int index = 1;
List<Integer> list = new ArrayList<>();
list.add(0);
list.add(1);
StatementParameters parameters = new StatementParameters();
parameters.setInParameter(index, "tableIndex", Types.BIGINT, list);
SelectSqlBuilder ssb1 = new SelectSqlBuilder();
ssb1.selectAll().from(TABLE_NAME).where(" tableIndex in (?) ").with(parameters).selectCount();
Number count1 = dao.count(ssb1, new DalHints().tableShardBy("tableIndex"));
assertEquals(3L, count1);
}
use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class DaoByFreeSql method getAllTasks.
public List<GenTaskByFreeSql> getAllTasks() throws SQLException {
DalHints hints = DalHints.createIfAbsent(null);
SelectSqlBuilder builder = new SelectSqlBuilder().selectAll();
List<GenTaskByFreeSql> list = client.query(builder, hints);
processList(list);
return list;
}
use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class DaoOfLoginUser method getAllUsers.
public List<LoginUser> getAllUsers() throws SQLException {
SelectSqlBuilder builder = new SelectSqlBuilder().selectAll();
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
return client.query(builder, hints);
}
use of com.ctrip.platform.dal.dao.sqlbuilder.SelectSqlBuilder in project dal by ctripcorp.
the class ConfigTemplateDao method getAllConfigTemplates.
public List<ConfigTemplate> getAllConfigTemplates() throws SQLException {
SelectSqlBuilder builder = new SelectSqlBuilder().selectAll();
DalHints hints = DalHints.createIfAbsent(null);
return client.query(builder, hints);
}
Aggregations