use of org.molgenis.data.support.BatchingQueryResult in project molgenis by molgenis.
the class PostgreSqlRepository method findAllBatching.
private BatchingQueryResult<Entity> findAllBatching(Query<Entity> q) {
return new BatchingQueryResult<Entity>(BATCH_SIZE, q) {
@Override
protected List<Entity> getBatch(Query<Entity> batchQuery) {
List<Object> parameters = new ArrayList<>();
String sql = getSqlSelect(getEntityType(), batchQuery, parameters, true);
RowMapper<Entity> entityMapper = postgreSqlEntityFactory.createRowMapper(getEntityType(), batchQuery.getFetch());
LOG.debug("Fetching [{}] data for query [{}]", getName(), batchQuery);
LOG.trace("SQL: {}, parameters: {}", sql, parameters);
Stopwatch sw = createStarted();
List<Entity> result = jdbcTemplate.query(sql, parameters.toArray(new Object[parameters.size()]), entityMapper);
LOG.trace("That took {}", sw);
return result;
}
};
}
Aggregations