Search in sources :

Example 1 with BatchingQueryResult

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;
        }
    };
}
Also used : Entity(org.molgenis.data.Entity) BatchingQueryResult(org.molgenis.data.support.BatchingQueryResult) Query(org.molgenis.data.Query) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) Stopwatch(com.google.common.base.Stopwatch)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Entity (org.molgenis.data.Entity)1 Query (org.molgenis.data.Query)1 BatchingQueryResult (org.molgenis.data.support.BatchingQueryResult)1