use of com.ctrip.platform.dal.dao.helper.DalColumnMapRowMapper in project dal by ctripcorp.
the class DalSingleResultExtractorTest method testExtract.
@Test
public void testExtract() {
DalColumnMapRowMapper mapper = new DalColumnMapRowMapper();
DalSingleResultExtractor test = new DalSingleResultExtractor(mapper, true);
}
use of com.ctrip.platform.dal.dao.helper.DalColumnMapRowMapper in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method testDalColumnMapRowMapperEmpty.
@Test
public void testDalColumnMapRowMapperEmpty() {
try {
StatementParameters parameters = new StatementParameters();
DalClient client = DalClientFactory.getClient(DATABASE_NAME);
List<Map<String, Object>> result1 = client.query(sqlNoResult, parameters, new DalHints(), new DalRowMapperExtractor<Map<String, Object>>(new DalColumnMapRowMapper()));
assertEquals(0, result1.size());
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
List<Map<String, Object>> result = dao.query(sqlNoResult, parameters, hints, new DalColumnMapRowMapper());
assertEquals(0, result.size());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.helper.DalColumnMapRowMapper in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method testDalColumnMapRowMapperOne.
@Test
public void testDalColumnMapRowMapperOne() {
try {
StatementParameters parameters = new StatementParameters();
parameters.set(1, Types.INTEGER, 3);
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
List<Map<String, Object>> result = dao.query(sqlObject, parameters, hints, new DalColumnMapRowMapper());
assertEquals(1, result.size());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.helper.DalColumnMapRowMapper in project dal by ctripcorp.
the class DalDirectClient method update.
@Override
public int update(String sql, StatementParameters parameters, final DalHints hints) throws SQLException {
final KeyHolder generatedKeyHolder = hints.getKeyHolder();
ConnectionAction<Integer> action = new ConnectionAction<Integer>() {
@Override
public Integer execute() throws Exception {
conn = getConnection(hints, this);
// For old generated free update, the parameters is not compiled before invoke direct client
parameters.compile();
if (generatedKeyHolder == null)
preparedStatement = createPreparedStatement(conn, sql, parameters, hints);
else
preparedStatement = createPreparedStatement(conn, sql, parameters, hints, generatedKeyHolder);
beginExecute();
int rows = executeUpdate(preparedStatement, entry);
endExectue();
if (generatedKeyHolder == null)
return rows;
rs = preparedStatement.getGeneratedKeys();
if (rs == null)
return rows;
DalRowMapperExtractor<Map<String, Object>> rse = new DalRowMapperExtractor<Map<String, Object>>(new DalColumnMapRowMapper());
generatedKeyHolder.addKeys(rse.extract(rs));
return rows;
}
};
action.populate(generatedKeyHolder == null ? DalEventEnum.UPDATE_SIMPLE : DalEventEnum.UPDATE_KH, sql, parameters);
return doInConnection(action, hints);
}
use of com.ctrip.platform.dal.dao.helper.DalColumnMapRowMapper in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method testDalColumnMapRowMapperList.
@Test
public void testDalColumnMapRowMapperList() {
try {
StatementParameters parameters = new StatementParameters();
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
List<Map<String, Object>> result = dao.query(sqlList, parameters, hints, new DalColumnMapRowMapper());
assertEquals(3, result.size());
} catch (Exception e) {
fail();
}
}
Aggregations