Search in sources :

Example 1 with ResultSetDocPartResult

use of com.torodb.backend.d2r.ResultSetDocPartResult in project torodb by torodb.

the class AbstractReadInterface method getCollectionResultSets.

@Override
@SuppressFBWarnings(value = { "OBL_UNSATISFIED_OBLIGATION", "ODR_OPEN_DATABASE_RESOURCE" }, justification = "ResultSet is wrapped in a DocPartResult. It's iterated and closed in caller code")
public List<DocPartResult> getCollectionResultSets(DSLContext dsl, MetaDatabase metaDatabase, MetaCollection metaCollection, Collection<Integer> dids) throws SQLException {
    ArrayList<DocPartResult> result = new ArrayList<>();
    Connection connection = dsl.configuration().connectionProvider().acquire();
    try {
        Iterator<? extends MetaDocPart> metaDocPartIterator = metaCollection.streamContainedMetaDocParts().sorted(TableRefComparator.MetaDocPart.DESC).iterator();
        while (metaDocPartIterator.hasNext()) {
            MetaDocPart metaDocPart = metaDocPartIterator.next();
            String statament = getDocPartStatament(metaDatabase, metaDocPart, dids);
            PreparedStatement preparedStatement = connection.prepareStatement(statament);
            result.add(new ResultSetDocPartResult(metaDataReadInterface, dataTypeProvider, errorHandler, metaDocPart, preparedStatement.executeQuery(), sqlHelper));
        }
    } finally {
        dsl.configuration().connectionProvider().release(connection);
    }
    return result;
}
Also used : ResultSetDocPartResult(com.torodb.backend.d2r.ResultSetDocPartResult) MetaDocPart(com.torodb.core.transaction.metainf.MetaDocPart) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSetDocPartResult(com.torodb.backend.d2r.ResultSetDocPartResult) DocPartResult(com.torodb.core.d2r.DocPartResult) PreparedStatement(java.sql.PreparedStatement) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

ResultSetDocPartResult (com.torodb.backend.d2r.ResultSetDocPartResult)1 DocPartResult (com.torodb.core.d2r.DocPartResult)1 MetaDocPart (com.torodb.core.transaction.metainf.MetaDocPart)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ArrayList (java.util.ArrayList)1