Search in sources :

Example 21 with FreeUpdateSqlBuilder

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

the class DaoOfUserProject method deleteUserProject.

public int deleteUserProject(int project_id) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("DELETE FROM user_project WHERE project_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "project_id", Types.INTEGER, project_id);
    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 22 with FreeUpdateSqlBuilder

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

the class UserGroupDao method deleteUserFromGroup.

public int deleteUserFromGroup(Integer user_id, Integer group_id) throws SQLException {
    FreeUpdateSqlBuilder builder = new FreeUpdateSqlBuilder(dbCategory);
    builder.setTemplate("DELETE FROM user_group WHERE user_id=? AND group_id=?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "user_id", Types.INTEGER, user_id);
    parameters.set(i++, "group_id", Types.INTEGER, group_id);
    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 23 with FreeUpdateSqlBuilder

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

the class FreeUpdateSqlBuilderTest method testDeleteFrom.

@Test
public void testDeleteFrom() throws SQLException {
    FreeUpdateSqlBuilder test = createTest();
    test.deleteFrom(noShardTableName);
    assertEquals("DELETE FROM " + wrappedNoShardTableName, test.build());
    test = createTest();
    test.deleteFrom(table(noShardTableName));
    assertEquals("DELETE FROM " + wrappedNoShardTableName, test.build());
    test = createTest();
    test.deleteFrom(table(noShardTableName));
    test.where(template);
    assertEquals("DELETE FROM " + wrappedNoShardTableName + " WHERE " + template, test.build());
}
Also used : FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) Test(org.junit.Test)

Example 24 with FreeUpdateSqlBuilder

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

the class FreeUpdateSqlBuilderTest method testUpdate.

@Test
public void testUpdate() throws SQLException {
    FreeUpdateSqlBuilder test = createTest();
    test.update(noShardTableName);
    assertEquals("UPDATE " + wrappedNoShardTableName, test.build());
    test = createTest();
    test.update(table(noShardTableName));
    assertEquals("UPDATE " + wrappedNoShardTableName, test.build());
    test = createTest();
}
Also used : FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) Test(org.junit.Test)

Example 25 with FreeUpdateSqlBuilder

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

the class FreeUpdateSqlBuilderTest method testDeleteFromMeltdown.

@Test
public void testDeleteFromMeltdown() throws SQLException {
    FreeUpdateSqlBuilder test = createTest();
    test.deleteFrom(noShardTableName);
    test.where().and(template, template, template);
    assertEquals("DELETE FROM " + wrappedNoShardTableName + " WHERE template AND template AND template", test.build());
}
Also used : FreeUpdateSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder) Test(org.junit.Test)

Aggregations

FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)27 DalHints (com.ctrip.platform.dal.dao.DalHints)20 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)20 Test (org.junit.Test)7 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)2 GenTaskByFreeSql (com.ctrip.platform.dal.daogen.entity.GenTaskByFreeSql)1 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)1