Search in sources :

Example 81 with StatementParameters

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

the class DaoByTableViewSp method updateTask.

public int updateTask(GenTaskByTableViewSp task) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    StringBuilder sb = new StringBuilder();
    sb.append("UPDATE task_table SET project_id=?,db_name=?,table_names=?,view_names=?,sp_names=?,");
    sb.append("prefix=?,suffix=?,cud_by_sp=?,pagination=?,`generated`=?,version=version+1,");
    sb.append("update_user_no=?,update_time=?,comment=?,sql_style=?,");
    sb.append("api_list=?,approved=?,approveMsg=? ");
    sb.append("WHERE id=? AND version=?");
    builder.setTemplate(sb.toString());
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "project_id", Types.INTEGER, task.getProject_id());
    parameters.set(i++, "db_name", Types.VARCHAR, task.getDatabaseSetName());
    parameters.set(i++, "table_names", Types.LONGVARCHAR, task.getTable_names());
    parameters.set(i++, "view_names", Types.LONGVARCHAR, task.getView_names());
    parameters.set(i++, "sp_names", Types.LONGVARCHAR, task.getSp_names());
    parameters.set(i++, "prefix", Types.VARCHAR, task.getPrefix());
    parameters.set(i++, "suffix", Types.VARCHAR, task.getSuffix());
    parameters.set(i++, "cud_by_sp", Types.BIT, task.getCud_by_sp());
    parameters.set(i++, "pagination", Types.BIT, task.getPagination());
    parameters.set(i++, "generated", Types.BIT, task.getGenerated());
    parameters.set(i++, "update_user_no", Types.VARCHAR, task.getUpdate_user_no());
    parameters.set(i++, "update_time", Types.TIMESTAMP, task.getUpdate_time());
    parameters.set(i++, "comment", Types.LONGVARCHAR, task.getComment());
    parameters.set(i++, "sql_style", Types.VARCHAR, task.getSql_style());
    parameters.set(i++, "api_list", Types.LONGVARCHAR, task.getApi_list());
    parameters.set(i++, "approved", Types.INTEGER, task.getApproved());
    parameters.set(i++, "approveMsg", Types.LONGVARCHAR, task.getApproveMsg());
    // parameters.set(i++, "length", Types.TINYINT, task.getLength());
    parameters.set(i++, "id", Types.INTEGER, task.getId());
    parameters.set(i++, "version", Types.INTEGER, task.getVersion());
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Example 82 with StatementParameters

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

the class DaoOfDatabaseSet method getAllDatabaseSetByName.

public List<DatabaseSet> getAllDatabaseSetByName(String name) throws SQLException {
    FreeSelectSqlBuilder<List<DatabaseSet>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, provider, shardingStrategy, groupId, update_user_no, update_time FROM databaseset WHERE name = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "name", Types.VARCHAR, name);
    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 83 with StatementParameters

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

the class DaoOfDatabaseSet method getAllDatabaseSetEntryByDbsetid.

public List<DatabaseSetEntry> getAllDatabaseSetEntryByDbsetid(Integer databaseSet_Id) throws SQLException {
    FreeSelectSqlBuilder<List<DatabaseSetEntry>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, databaseType, sharding, connectionString, databaseSet_Id, update_user_no, update_time FROM databasesetentry WHERE databaseSet_Id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "databaseSet_Id", Types.INTEGER, databaseSet_Id);
    builder.mapWith(databaseSetEntryRowMapper);
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    List<DatabaseSetEntry> list = queryDao.query(builder, parameters, hints);
    processEntryList(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) DatabaseSetEntry(com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry)

Example 84 with StatementParameters

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

the class DaoOfDatabaseSet method getAllDatabaseSetByGroupId.

public List<DatabaseSet> getAllDatabaseSetByGroupId(Integer groupId) throws SQLException {
    FreeSelectSqlBuilder<List<DatabaseSet>> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, name, provider, shardingStrategy, groupId, update_user_no, update_time FROM databaseset WHERE groupId = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "groupId", Types.INTEGER, groupId);
    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 85 with StatementParameters

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

the class DaoOfDatabaseSet method deleteDatabaseSetEntryByDbsetId.

/**
 * 依据外键databaseSet_Id删除entry
 *
 * @param dbsetId
 * @return
 */
public int deleteDatabaseSetEntryByDbsetId(Integer dbsetId) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("DELETE FROM databasesetentry WHERE databaseSet_Id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.setSensitive(i++, "databaseSet_Id", Types.INTEGER, dbsetId);
    DalHints hints = DalHints.createIfAbsent(null);
    return queryDao.update(builder, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Aggregations

StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)360 DalHints (com.ctrip.platform.dal.dao.DalHints)317 Test (org.junit.Test)209 SQLException (java.sql.SQLException)102 ArrayList (java.util.ArrayList)51 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)40 ClientTestModel (test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel)40 List (java.util.List)29 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)20 DalQueryDao (com.ctrip.platform.dal.dao.DalQueryDao)19 DalTableDao (com.ctrip.platform.dal.dao.DalTableDao)17 After (org.junit.After)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 DalDefaultJpaParser (com.ctrip.platform.dal.dao.helper.DalDefaultJpaParser)14 ResultSet (java.sql.ResultSet)10 DalClient (com.ctrip.platform.dal.dao.DalClient)9 AfterClass (org.junit.AfterClass)9 BeforeClass (org.junit.BeforeClass)9 AbstractFreeSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.AbstractFreeSqlBuilder)8 Map (java.util.Map)8