use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientTestStub method batchCallTestForSpWithOutParameter.
/**
* Test batch call with parameters and has ResultParameters
* @throws SQLException
*/
@Test
public void batchCallTestForSpWithOutParameter() throws SQLException {
// Oracle do not support out parameter for batch store procedure update
if (!diff.supportBatchSpWithOutParameter)
return;
String callSql = "{call " + SP_WITH_OUT_PARAM + "(?,?)}";
StatementParameters[] parametersList = new StatementParameters[3];
for (int i = 0; i < 3; i++) {
StatementParameters parameters = new StatementParameters();
parameters.set("v_id", Types.INTEGER, i + 1);
parameters.registerOut("count", Types.INTEGER);
parametersList[i] = parameters;
}
DalHints hints = new DalHints();
int[] res = client.batchCall(callSql, parametersList, hints);
Assert.assertEquals(3, res.length);
List<ClientTestModel> models = this.queryModelsByIds(1, 2, 3);
Assert.assertEquals(0, models.size());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientTestStub method queryTestWithParameters.
/**
* Test the basic query function without parameters
*
* @throws SQLException
*/
@Test
public void queryTestWithParameters() throws SQLException {
String querySql = "SELECT * FROM " + TABLE_NAME + " WHERE type = ?";
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.SMALLINT, 1);
ClientTestDalRowMapper mapper = new ClientTestDalRowMapper();
DalHints hints = new DalHints();
List<ClientTestModel> res = client.query(querySql, parameters, hints, new DalRowMapperExtractor<ClientTestModel>(mapper));
Assert.assertTrue(null != res);
Assert.assertEquals(2, res.size());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientTestStub method updateTestWithoutParameters.
/**
* Test the update function without parameters
*
* @throws SQLException
*/
@Test
public void updateTestWithoutParameters() throws SQLException {
String updateSql = String.format("UPDATE %s SET address=%s WHERE id=%s", TABLE_NAME, "'BJ INFO'", 1);
StatementParameters parameters = new StatementParameters();
DalHints hints = new DalHints();
int count = client.update(updateSql, parameters, hints);
assertEquals(1, count, 3);
List<ClientTestModel> po_models = this.queryModelsByIds(1);
Assert.assertTrue(null != po_models);
Assert.assertEquals(1, po_models.size());
Assert.assertEquals("BJ INFO", po_models.get(0).getAddress());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientTestStub method callTestWithParametersForSpWithoutOutParameter.
/**
* Test call with parameters but has no resultsParameter
* @throws SQLException
*/
@Test
public void callTestWithParametersForSpWithoutOutParameter() throws SQLException {
String callSql = "{call " + SP_WITHOUT_OUT_PARAM + "(?,?,?,?)}";
StatementParameters parameters = new StatementParameters();
parameters.set("v_id", Types.INTEGER, 4);
parameters.set("v_quantity", Types.INTEGER, 10);
parameters.set("v_type", Types.SMALLINT, 3);
parameters.set("v_address", Types.VARCHAR, "SZ INFO");
DalHints hints = new DalHints();
Map<String, ?> res = client.call(callSql, parameters, hints);
Assert.assertTrue(null != res);
Assert.assertEquals(0, res.size());
List<ClientTestModel> models = this.queryModelsByIds();
Assert.assertEquals(4, models.size());
}
use of com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryFirstNullableSuccess.
/**
* Test query for first success
* @throws SQLException
*/
@Test
public void testQueryFirstNullableSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
ClientTestModel model = client.queryFirstNullable(sql, param, hints, mapper);
Assert.assertEquals(1, model.getId().intValue());
}
Aggregations