Search in sources :

Example 51 with DalHints

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

the class DalTableDaoShardByDbOracleTest method tearDownAfterClass.

@AfterClass
public static void tearDownAfterClass() throws Exception {
    for (int i = 0; i < mod; i++) {
        DalHints hints = new DalHints();
        String[] sqls = new String[] { DROP_TABLE_SEQ, DROP_TABLE_TRIG, DROP_TABLE_SQL };
        client.batchUpdate(sqls, hints.inShard(i));
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) AfterClass(org.junit.AfterClass)

Example 52 with DalHints

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

the class DalTableDaoShardByDbOracleTest 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 53 with DalHints

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

the class DalTableDaoShardByDbSqlSvrTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    DalClientFactory.initClientFactory();
    clientSqlSvr = DalClientFactory.getClient(DATABASE_NAME_SQLSVR);
    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 54 with DalHints

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

the class DalQueryDaoTest method testQueryListAllShardsWithRowCallbackSequential.

@Test
public void testQueryListAllShardsWithRowCallbackSequential() {
    try {
        DalHints hints = new DalHints();
        TestDalRowCallback callback = new TestDalRowCallback();
        dao.query(sqlListQuantity, parameters(), hints.inAllShards().sequentialExecute(), callback);
        // 66 = (10 + 11 + 12)*2
        assertEquals(66, callback.result.get());
    } catch (Exception e) {
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 55 with DalHints

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

the class DalQueryDaoTest method testQueryListAllShardsWithRowCallbackSequentialAsync.

@Test
public void testQueryListAllShardsWithRowCallbackSequentialAsync() {
    try {
        DalHints hints = new DalHints();
        TestDalRowCallback callback = new TestDalRowCallback();
        dao.query(sqlListQuantity, parameters(), hints.inAllShards().sequentialExecute().asyncExecution(), callback);
        // Make sure the execution is completed
        hints.getAsyncResult().get();
        // 66 = (10 + 11 + 12)*2
        assertEquals(66, callback.result.get());
    } catch (Exception e) {
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) SQLException(java.sql.SQLException) Test(org.junit.Test)

Aggregations

DalHints (com.ctrip.platform.dal.dao.DalHints)772 Test (org.junit.Test)532 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)317 SQLException (java.sql.SQLException)298 ArrayList (java.util.ArrayList)132 ClientTestModel (test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel)61 List (java.util.List)48 KeyHolder (com.ctrip.platform.dal.dao.KeyHolder)45 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)39 Future (java.util.concurrent.Future)32 DalTableDao (com.ctrip.platform.dal.dao.DalTableDao)29 SelectionContext (com.ctrip.platform.dal.dao.configure.SelectionContext)27 DalDefaultJpaParser (com.ctrip.platform.dal.dao.helper.DalDefaultJpaParser)27 DataBase (com.ctrip.platform.dal.dao.configure.DataBase)26 BeforeClass (org.junit.BeforeClass)26 AfterClass (org.junit.AfterClass)25 HashMap (java.util.HashMap)23 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)20 DalClient (com.ctrip.platform.dal.dao.DalClient)18 BatchUpdateTask (com.ctrip.platform.dal.dao.task.BatchUpdateTask)18