Search in sources :

Example 16 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class DaoOfDatabaseSet method getAllDatabaseSetByGroupIdAndModeType.

public List<DatabaseSet> getAllDatabaseSetByGroupIdAndModeType(Integer groupId, String modeType) throws SQLException {
    FreeSelectSqlBuilder<List<DatabaseSet>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, provider, shardingStrategy, groupId, update_user_no, update_time, mode_type FROM databaseset WHERE groupId = ? and mode_type = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "groupId", Types.INTEGER, groupId);
    parameters.set(i++, "mode_type", Types.VARCHAR, modeType);
    builder.mapWith(databaseSetRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<DatabaseSet> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) DatabaseSet(com.ctrip.platform.dal.daogen.entity.DatabaseSet) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Example 17 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class DaoOfProject method getProjectByConfigname.

public List<Project> getProjectByConfigname(String dal_config_name) throws SQLException {
    FreeSelectSqlBuilder<List<Project>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, namespace,dal_group_id,dal_config_name,update_user_no,update_time FROM project WHERE dal_config_name = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "dal_config_name", Types.VARCHAR, dal_config_name);
    builder.mapWith(projectRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<Project> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Project(com.ctrip.platform.dal.daogen.entity.Project) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Example 18 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class DaoOfProject method getProjectByGroupId.

public List<Project> getProjectByGroupId(int groupId) throws SQLException {
    FreeSelectSqlBuilder<List<Project>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, namespace,dal_group_id,dal_config_name,update_user_no,update_time FROM project WHERE dal_group_id = ?  order by id desc");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "dal_group_id", Types.INTEGER, groupId);
    builder.mapWith(projectRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<Project> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Project(com.ctrip.platform.dal.daogen.entity.Project) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List)

Example 19 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class ApproveTaskDao method getAllApproveTaskByApproverId.

public List<ApproveTask> getAllApproveTaskByApproverId(Integer approverId) throws SQLException {
    FreeSelectSqlBuilder<List<ApproveTask>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, task_id, task_type, create_time, create_user_id, approve_user_id FROM approve_task WHERE approve_user_id=?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "approve_user_id", Types.INTEGER, approverId);
    builder.mapWith(approveTaskRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<ApproveTask> list = queryDao.query(builder, parameters, hints);
    processList(list);
    return list;
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) List(java.util.List) ApproveTask(com.ctrip.platform.dal.daogen.entity.ApproveTask)

Example 20 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class DalGroupDBDao method getDbAllinOneNamesByModeType.

public List<String> getDbAllinOneNamesByModeType(String modeType) throws SQLException {
    FreeSelectSqlBuilder<List<String>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT dbname FROM alldbs where mode_type = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "mode_type", Types.VARCHAR, modeType);
    builder.mapWith(dalGroupDBRowMapper).simpleType();
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    return queryDao.query(builder, parameters, hints);
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)61 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)44 DalHints (com.ctrip.platform.dal.dao.DalHints)38 List (java.util.List)38 ArrayList (java.util.ArrayList)22 Test (org.junit.Test)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 DalQueryDao (com.ctrip.platform.dal.dao.DalQueryDao)6 ShortRowMapper (com.ctrip.platform.dal.dao.helper.ShortRowMapper)6 DalDefaultJpaMapper (com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper)4 DatabaseSet (com.ctrip.platform.dal.daogen.entity.DatabaseSet)3 GenTaskByFreeSql (com.ctrip.platform.dal.daogen.entity.GenTaskByFreeSql)3 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)3 DalCustomRowMapper (com.ctrip.platform.dal.dao.helper.DalCustomRowMapper)2 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)2 DatabaseSetEntry (com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry)2 GenTaskByTableViewSp (com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)2 Project (com.ctrip.platform.dal.daogen.entity.Project)2 Map (java.util.Map)2 ClientTestModel (com.ctrip.platform.dal.dao.unitbase.ClientTestModel)1