use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalConnectionTest method testApplyHints.
@Test
public void testApplyHints() throws SQLException {
Connection conn = null;
try {
DalConnection test = getConnection();
DalHints hints = new DalHints();
hints.setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
test.applyHints(hints);
conn = test.getConn();
assertTrue(conn.getTransactionIsolation() == Connection.TRANSACTION_SERIALIZABLE);
hints.setIsolationLevel(Connection.TRANSACTION_NONE);
test.applyHints(hints);
assertTrue(conn.getTransactionIsolation() == Connection.TRANSACTION_NONE);
} catch (Throwable e) {
fail();
e.printStackTrace();
} finally {
if (conn != null)
conn.close();
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalDefaultJpaParserSqlServerTest2 method testBatch.
@Test
public void testBatch() throws SQLException {
ClientTestModel[] models = new ClientTestModel[ROW_COUNT];
for (int i = 0; i < ROW_COUNT; i++) {
ClientTestModel model = new ClientTestModel();
model.setQuantity(10 + 1 % 3);
model.setType(((Number) (1 % 3)).shortValue());
model.setAddress("CTRIP");
models[i] = model;
}
DalHints hints = new DalHints();
int[] res = dao.batchInsert(hints, Arrays.asList(models));
Assert.assertEquals(ROW_COUNT, res.length);
StatementParameters parameters = new StatementParameters();
List<ClientTestModel> db_models = dao.query("1=1", parameters, hints);
Assert.assertEquals(ROW_COUNT, db_models.size());
dao.delete(hints, db_models);
Assert.assertEquals(0, DalTestHelper.getCount(dao));
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalDefaultJpaParserSqlServerTest2 method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() {
DalHints hints = new DalHints();
String[] sqls = new String[] { String.format(DROP_TABLE_SQL, parser.getTableName(), parser.getTableName()), String.format(CREATE_TABLE_SQL, parser.getTableName()) };
try {
client.batchUpdate(sqls, hints);
} catch (SQLException e) {
e.printStackTrace();
Assert.fail();
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalDefaultJpaParserMySqlTest2 method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
DalHints hints = new DalHints();
String[] sqls = new String[] { String.format(DROP_TABLE_SQL, parser.getTableName()), String.format(CREATE_TABLE_SQL, parser.getTableName()) };
client.batchUpdate(sqls, hints);
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalDefaultJpaParserMySqlTest2 method test.
@Test
public void test() throws SQLException {
ClientTestModel[] models = new ClientTestModel[ROW_COUNT];
for (int i = 0; i < ROW_COUNT; i++) {
ClientTestModel model = new ClientTestModel();
model.setQuantity(10 + 1 % 3);
model.setType(((Number) (1 % 3)).shortValue());
model.setAddress("CTRIP");
models[i] = model;
}
DalHints hints = new DalHints();
int[] res = dao.insert(hints, Arrays.asList(models));
assertEquals(ROW_COUNT, res);
StatementParameters parameters = new StatementParameters();
List<ClientTestModel> db_models = dao.query("true", parameters, hints);
Assert.assertNotNull(db_models.get(1).getId());
Assert.assertTrue(db_models.get(2).getId() > 0);
Assert.assertEquals(ROW_COUNT, db_models.size());
res = dao.delete(hints, db_models);
assertEquals(ROW_COUNT, res);
}
Aggregations