use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class DaoByTableViewSp method updateAndGetTasks.
public List<GenTaskByTableViewSp> updateAndGetTasks(int projectId) throws SQLException {
FreeSelectSqlBuilder<List<GenTaskByTableViewSp>> builder = new FreeSelectSqlBuilder<>(dbCategory);
StringBuilder sb = new StringBuilder();
sb.append("SELECT id, project_id,db_name,table_names,view_names,sp_names,prefix,suffix,cud_by_sp,pagination,`generated`,version,update_user_no,update_time,comment,sql_style,api_list,approved,approveMsg ");
sb.append("FROM task_table 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(genTaskByTableViewSpRowMapper);
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
List<GenTaskByTableViewSp> list = queryDao.query(builder, parameters, hints);
List<GenTaskByTableViewSp> result = new ArrayList<>();
if (list == null || list.size() == 0)
return result;
processList(list);
for (GenTaskByTableViewSp 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 DaoOfDatabaseSet method getMasterDatabaseSetEntryByDatabaseSetName.
public DatabaseSetEntry getMasterDatabaseSetEntryByDatabaseSetName(String dbName) throws SQLException {
FreeSelectSqlBuilder<DatabaseSetEntry> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT en.id, en.name, en.databaseType, en.sharding, en.connectionString, en.databaseSet_Id, en.update_user_no, en.update_time " + "FROM databasesetentry as en join databaseset as se on en.databaseSet_Id = se.id " + "WHERE se.name = ? and en.databaseType = 'Master' limit 1");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "name", Types.VARCHAR, dbName);
builder.mapWith(databaseSetEntryRowMapper).requireFirst().nullable();
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
DatabaseSetEntry entry = queryDao.query(builder, parameters, hints);
processDatabaseSetEntry(entry);
return entry;
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class GroupRelationDao method getAllGroupRelationByCurrentGroupId.
public List<GroupRelation> getAllGroupRelationByCurrentGroupId(Integer currentGroupId) throws SQLException {
FreeSelectSqlBuilder<List<GroupRelation>> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE current_group_id = ?");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "current_group_id", Types.INTEGER, currentGroupId);
builder.mapWith(groupRelationRowMapper);
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 GroupRelationDao method getAllGroupRelationByChildGroupId.
public List<GroupRelation> getAllGroupRelationByChildGroupId(Integer childGroupId) throws SQLException {
FreeSelectSqlBuilder<List<GroupRelation>> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE child_group_id = ?");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "child_group_id", Types.INTEGER, childGroupId);
builder.mapWith(groupRelationRowMapper);
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 GroupRelationDao method getGroupRelationByCurrentGroupIdAndChildGroupId.
public GroupRelation getGroupRelationByCurrentGroupIdAndChildGroupId(Integer currentGroupId, Integer childGroupId) throws SQLException {
FreeSelectSqlBuilder<GroupRelation> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE current_group_id = ? AND child_group_id = ?");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "current_group_id", Types.INTEGER, currentGroupId);
parameters.set(i++, "child_group_id", Types.INTEGER, childGroupId);
builder.mapWith(groupRelationRowMapper).requireFirst().nullable();
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
return queryDao.query(builder, parameters, hints);
}
Aggregations