Search in sources :

Example 66 with StatementParameters

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

the class DalQueryDaoSqlSvrTest method tearDown.

@After
public void tearDown() throws Exception {
    String sql = "DELETE FROM " + TABLE_NAME;
    StatementParameters parameters = new StatementParameters();
    DalHints hints = new DalHints();
    sql = "DELETE FROM " + TABLE_NAME;
    parameters = new StatementParameters();
    hints = new DalHints();
    for (int i = 0; i < mod; i++) {
        clientSqlSvr.update(sql, parameters, hints.inShard(i));
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) After(org.junit.After)

Example 67 with StatementParameters

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

the class DalQueryDaoSqlSvrTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    DalHints hints = new DalHints();
    String[] sqls = null;
    // For SQL server
    hints = new DalHints();
    StatementParameters parameters = new StatementParameters();
    for (int i = 0; i < mod; i++) {
        sqls = new String[] { DROP_TABLE_SQL_SQLSVR_TPL, CREATE_TABLE_SQL_SQLSVR_TPL };
        for (int j = 0; j < sqls.length; j++) {
            clientSqlSvr.update(sqls[j], parameters, hints.inShard(i));
        }
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) BeforeClass(org.junit.BeforeClass)

Example 68 with StatementParameters

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

the class DalQueryDaoTest method testQueryFirstAllShardsNullableAsync.

@Test
public void testQueryFirstAllShardsNullableAsync() {
    try {
        DalHints hints = new DalHints();
        StatementParameters parameters = new StatementParameters();
        ClientTestModel result = dao.queryFirstNullable(sqlNoResult, parameters(), hints.inAllShards().asyncExecution(), new ClientTestDalRowMapper());
        assertNull(result);
        Future<ClientTestModel> fr = (Future<ClientTestModel>) hints.getAsyncResult();
        result = fr.get();
        assertNull(result);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) Future(java.util.concurrent.Future) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 69 with StatementParameters

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

the class DalQueryDaoOracleTest method tearDown.

@After
public void tearDown() throws Exception {
    String sql = "DELETE FROM " + TABLE_NAME;
    StatementParameters parameters = new StatementParameters();
    DalHints hints = new DalHints();
    try {
        for (int i = 0; i < mod; i++) {
            client.update(sql, parameters, hints.inShard(i));
        }
    } catch (SQLException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) SQLException(java.sql.SQLException) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) After(org.junit.After)

Example 70 with StatementParameters

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

the class DalQueryDaoTest method testQueryForObjectAllShardsNullable.

@Test
public void testQueryForObjectAllShardsNullable() {
    try {
        DalHints hints = new DalHints();
        StatementParameters parameters = new StatementParameters();
        ClientTestModel result = dao.queryForObjectNullable(sqlNoResult, parameters(), hints.inAllShards(), new ClientTestDalRowMapper());
        assertNull(result);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) SQLException(java.sql.SQLException) Test(org.junit.Test)

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