* Create and return an {@link SelectIterator} for the class using a prepared statement.
*/
public SelectIterator<T, ID> buildIterator(BaseDaoImpl<T, ID> classDao, ConnectionSource connectionSource,
PreparedStmt<T> preparedStmt) throws SQLException {
DatabaseConnection connection = connectionSource.getReadOnlyConnection();
CompiledStatement compiledStatement = null;
try {
compiledStatement = preparedStmt.compile(connection);
SelectIterator<T, ID> iterator =
new SelectIterator<T, ID>(tableInfo.getDataClass(), classDao, preparedStmt, connectionSource,
connection, compiledStatement, preparedStmt.getStatement());
connection = null;
compiledStatement = null;
return iterator;
} finally {
if (compiledStatement != null) {
compiledStatement.close();
}
if (connection != null) {
connectionSource.releaseConnection(connection);
}
}