new CallTemplate<Integer>() {
@Override
Integer doCall(String sql, MapSqlParameterSource params) {
final RowMapper<T> mapper = new BeanPropertyRowMapper<T>(resultSetClass);
NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource) {
@Override
protected PreparedStatementCreator getPreparedStatementCreator(String sql,
SqlParameterSource paramSource) {
PreparedStatementCreator originalCreator = super.getPreparedStatementCreator(sql, paramSource);
return new StreamingStatementCreator(originalCreator);
}
};
final AtomicInteger rowNum = new AtomicInteger(0);
template.query(sql, params, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
handler.handleRow(mapper.mapRow(rs, rowNum.incrementAndGet()));
}