Search in sources :

Example 46 with DalHints

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

the class DalTabelDaoShardByTableSqlSvrTest 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[] { String.format(DROP_TABLE_SQL_SQLSVR_TPL, i, i), String.format(CREATE_TABLE_SQL_SQLSVR_TPL, i) };
        for (int j = 0; j < sqls.length; j++) {
            clientSqlSvr.update(sqls[j], parameters, hints);
        }
    }
    clientSqlSvr.update(DROP_TABLE_SQL_SQLSVR_TPL_1, parameters, hints);
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters) BeforeClass(org.junit.BeforeClass)

Example 47 with DalHints

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

the class DalQueryDaoTest method testQueryFirstAllShards.

@Test
public void testQueryFirstAllShards() {
    try {
        DalHints hints = new DalHints();
        ClientTestModel result = queryFirstInAllShard(hints);
        assertNotNull(result);
        assertEquals(1, result.id);
    } catch (Exception e) {
        fail();
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 48 with DalHints

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

the class DalTabelDaoShardByTableMySqlTest 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++) {
            clientMySql.update(sql + "_" + i, parameters, hints);
        }
    } 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 49 with DalHints

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

the class DalTabelDaoShardByTableMySqlTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    DalClientFactory.initClientFactory();
    clientMySql = DalClientFactory.getClient(DATABASE_NAME_MYSQL);
    DalHints hints = new DalHints();
    String[] sqls = null;
    for (int i = 0; i < mod; i++) {
        sqls = new String[] { DROP_TABLE_SQL_MYSQL, String.format(DROP_TABLE_SQL_MYSQL_TPL, i), String.format(CREATE_TABLE_SQL_MYSQL_TPL, i) };
        clientMySql.batchUpdate(sqls, hints);
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) BeforeClass(org.junit.BeforeClass)

Example 50 with DalHints

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

the class DalTableDaoShardByDbOracleTest method setUp.

@Before
public void setUp() throws Exception {
    setUpBeforeClass();
    DalHints hints = new DalHints();
    String[] insertSqls = null;
    for (int i = 0; i < mod; i++) {
        insertSqls = new String[5];
        insertSqls[0] = DROP_TABLE_SEQ;
        insertSqls[1] = CREATE_TABLE_SEQ;
        insertSqls = new String[] { "INSERT INTO " + TABLE_NAME + "(quantity,tableIndex,type,address)" + " VALUES(10, " + i + " ,1, 'SH INFO')", "INSERT INTO " + TABLE_NAME + "(quantity,tableIndex,type,address)" + " VALUES(11, " + i + " ,1, 'BJ INFO')", "INSERT INTO " + TABLE_NAME + "(quantity,tableIndex,type,address)" + " VALUES(12, " + i + " ,1, 'SZ INFO')" };
        client.batchUpdate(insertSqls, hints.inShard(i));
    }
}
Also used : DalHints(com.ctrip.platform.dal.dao.DalHints) Before(org.junit.Before)

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