use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder 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"));
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class DalGroupDBDao method getGroupDBByDbName.
public DalGroupDB getGroupDBByDbName(String dbname) throws SQLException {
FreeSelectSqlBuilder<DalGroupDB> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT id, dbname, comment,dal_group_id, db_address, db_port, db_user, db_password, db_catalog, db_providerName, mode_type FROM alldbs WHERE dbname=?");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "dbname", Types.VARCHAR, dbname);
builder.mapWith(dalGroupDBRowMapper).requireFirst().nullable();
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
return queryDao.query(builder, parameters, hints);
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class DalGroupDBDao method getDalClusterGroupDbsByGroupId.
public List<DalGroupDB> getDalClusterGroupDbsByGroupId(int groupId, String dbModeType) throws SQLException {
FreeSelectSqlBuilder<List<DalGroupDB>> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT id, dbname, comment,dal_group_id, db_address, db_port, db_user, db_password, db_catalog, db_providerName, mode_type FROM alldbs WHERE dal_group_id=? and mode_type=?");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "dal_group_id", Types.INTEGER, groupId);
parameters.set(i++, "mode_type", Types.VARCHAR, dbModeType);
builder.mapWith(dalGroupDBRowMapper);
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
return queryDao.query(builder, parameters, hints);
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class DaoByFreeSql method updateAndGetTasks.
public List<GenTaskByFreeSql> updateAndGetTasks(int projectId) throws SQLException {
FreeSelectSqlBuilder<List<GenTaskByFreeSql>> builder = new FreeSelectSqlBuilder<>(dbCategory);
StringBuilder sb = new StringBuilder();
sb.append("SELECT id, project_id, db_name, class_name,pojo_name,method_name,crud_type,sql_content,parameters,`generated`,version,update_user_no,update_time,comment,scalarType,pojoType,pagination,sql_style,approved,approveMsg,hints ");
sb.append("FROM task_sql WHERE project_id=? AND `generated`=FALSE");
builder.setTemplate(sb.toString());
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "project_id", Types.INTEGER, projectId);
builder.mapWith(genTaskByFreeSqlRowMapper);
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
List<GenTaskByFreeSql> list = queryDao.query(builder, parameters, hints);
List<GenTaskByFreeSql> result = new ArrayList<>();
if (list == null || list.size() == 0)
return result;
processList(list);
for (GenTaskByFreeSql entity : list) {
entity.setGenerated(true);
if (updateTask(entity) > 0) {
result.add(entity);
}
}
return result;
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class DaoByFreeSql method getTasksByProjectId.
public List<GenTaskByFreeSql> getTasksByProjectId(int projectId) throws SQLException {
FreeSelectSqlBuilder<List<GenTaskByFreeSql>> builder = new FreeSelectSqlBuilder<>(dbCategory);
StringBuilder sb = new StringBuilder();
sb.append("SELECT id, project_id, mode_type, db_name, class_name,pojo_name,method_name,crud_type,sql_content,parameters,`generated`,version,update_user_no,update_time,comment,scalarType,pojoType,pagination,sql_style,approved,approveMsg,hints ");
sb.append("FROM task_sql WHERE project_id=? order by id");
builder.setTemplate(sb.toString());
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "project_id", Types.INTEGER, projectId);
builder.mapWith(genTaskByFreeSqlRowMapper);
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
List<GenTaskByFreeSql> list = queryDao.query(builder, parameters, hints);
processList(list);
return list;
}
Aggregations