use of com.revolsys.record.RecordFactory in project com.revolsys.open by revolsys.
the class PostgreSQLJdbcQueryResultPager method getList.
@Override
public List<Record> getList() {
synchronized (this) {
if (this.results == null) {
final ArrayList<Record> results = new ArrayList<>();
final int pageSize = getPageSize();
final int pageNumber = getPageNumber();
if (pageNumber != -1) {
String sql = getSql();
final int startRowNum = (pageNumber - 1) * pageSize;
sql = getSql() + " OFFSET " + startRowNum + " LIMIT " + pageSize;
final RecordDefinition recordDefinition = getRecordDefinition();
if (recordDefinition != null) {
final RecordFactory recordFactory = getRecordFactory();
final JdbcRecordStore recordStore = getRecordStore();
try (JdbcConnection connection = recordStore.getJdbcConnection()) {
final List<FieldDefinition> attributes = recordDefinition.getFields();
try (final PreparedStatement statement = connection.prepareStatement(sql);
final ResultSet resultSet = JdbcQueryIterator.getResultSet(statement, getQuery())) {
if (resultSet.next()) {
int i = 0;
do {
final Record object = JdbcQueryIterator.getNextRecord(recordStore, recordDefinition, attributes, recordFactory, resultSet, this.internStrings);
results.add(object);
i++;
} while (resultSet.next() && i < pageSize);
}
} catch (final SQLException e) {
throw connection.getException("updateResults", sql, e);
}
}
}
}
this.results = results;
}
return this.results;
}
}
Aggregations