use of com.ctrip.platform.dal.dao.helper.HintsAwareExtractor in project dal by ctripcorp.
the class DalDirectClient method query.
@Override
public List<?> query(String sql, StatementParameters parameters, final DalHints hints, final List<DalResultSetExtractor<?>> extractors) throws SQLException {
ConnectionAction<List<?>> action = new ConnectionAction<List<?>>() {
@Override
public List<?> execute() throws Exception {
conn = getConnection(hints, this);
preparedStatement = createPreparedStatement(conn, sql, parameters, hints);
List<Object> result = new ArrayList<>();
DalWatcher.beginExecute();
preparedStatement.execute();
for (DalResultSetExtractor<?> extractor : extractors) {
ResultSet resultSet = preparedStatement.getResultSet();
Object partResult;
if (extractor instanceof HintsAwareExtractor)
partResult = ((DalResultSetExtractor) ((HintsAwareExtractor) extractor).extractWith(hints)).extract(resultSet);
else
partResult = extractor.extract(resultSet);
result.add(partResult);
preparedStatement.getMoreResults();
}
DalWatcher.endExectue();
return result;
}
};
action.populate(DalEventEnum.QUERY, sql, parameters);
return doInConnection(action, hints);
}
Aggregations