public ResultSetIterable<ArchiveEntry> findArchivesForIndex(Connection con, IndexEntry indexEntry) { return con.createQuery("select archive.id, archive.archiveId, archive.nameHash," + " archive.crc, archive.revision, archive.hash from index_archive " + "join archive on index_archive.archive = archive.id " + "where index_archive.index = :id") .addParameter("id", indexEntry.getId()) .executeAndFetchLazy(ArchiveEntry.class); }
public <T> List<T> executeAndFetch(ResultSetHandlerFactory<T> factory){ List<T> list = new ArrayList<>(); try (ResultSetIterable<T> iterable = executeAndFetchLazy(factory)) { for (T item : iterable) { list.add(item); } } return list; }
/** * Read a collection lazily. Generally speaking, this should only be used if you are reading MANY * results and keeping them all in a Collection would cause memory issues. You MUST call * {@link org.sql2o.ResultSetIterable#close()} when you are done iterating. * * @param resultSetHandler ResultSetHandler * @return iterable results */ public <T> ResultSetIterable<T> executeAndFetchLazy(final ResultSetHandler<T> resultSetHandler) { final ResultSetHandlerFactory<T> factory = newResultSetHandlerFactory(resultSetHandler); return executeAndFetchLazy(factory); }
public <T> T executeAndFetchFirst(ResultSetHandlerFactory<T> resultSetHandlerFactory){ try (ResultSetIterable<T> iterable = executeAndFetchLazy(resultSetHandlerFactory)) { Iterator<T> iterator = iterable.iterator(); return iterator.hasNext() ? iterator.next() : null; } }
/** * Read a collection lazily. Generally speaking, this should only be used if you are reading MANY * results and keeping them all in a Collection would cause memory issues. You MUST call * {@link org.sql2o.ResultSetIterable#close()} when you are done iterating. * * @param returnType type of each row * @return iterable results */ public <T> ResultSetIterable<T> executeAndFetchLazy(final Class<T> returnType) { final ResultSetHandlerFactory<T> resultSetHandlerFactory = newResultSetHandlerFactory(returnType); return executeAndFetchLazy(resultSetHandlerFactory); }
public <T> List<T> executeAndFetch(ResultSetHandlerFactory<T> factory){ List<T> list = new ArrayList<>(); try (ResultSetIterable<T> iterable = executeAndFetchLazy(factory)) { for (T item : iterable) { list.add(item); } } return list; }
public <T> List<T> executeAndFetch(ResultSetHandlerFactory<T> factory) { List<T> list = new ArrayList<>(); try (ResultSetIterable<T> iterable = executeAndFetchLazy(factory)) { for (T item : iterable) { list.add(item); } } return list; }
/** * Read a collection lazily. Generally speaking, this should only be used if you are reading MANY * results and keeping them all in a Collection would cause memory issues. You MUST call * {@link ResultSetIterable#close()} when you are done iterating. * * @param returnType type of each row * @return iterable results */ public <T> ResultSetIterable<T> executeAndFetchLazy(final Class<T> returnType) { final ResultSetHandlerFactory<T> resultSetHandlerFactory = newResultSetHandlerFactory(returnType); return executeAndFetchLazy(resultSetHandlerFactory); }
public <T> T executeAndFetchFirst(ResultSetHandlerFactory<T> resultSetHandlerFactory) { try (ResultSetIterable<T> iterable = executeAndFetchLazy(resultSetHandlerFactory)) { Iterator<T> iterator = iterable.iterator(); return iterator.hasNext() ? iterator.next() : null; } }
/** * Read a collection lazily. Generally speaking, this should only be used if you are reading MANY * results and keeping them all in a Collection would cause memory issues. You MUST call * {@link org.sql2o.ResultSetIterable#close()} when you are done iterating. * * @param resultSetHandler ResultSetHandler * @return iterable results */ public <T> ResultSetIterable<T> executeAndFetchLazy(final ResultSetHandler<T> resultSetHandler) { final ResultSetHandlerFactory<T> factory = newResultSetHandlerFactory(resultSetHandler); return executeAndFetchLazy(factory); }
/** * Read a collection lazily. Generally speaking, this should only be used if you are reading MANY * results and keeping them all in a Collection would cause memory issues. You MUST call * {@link ResultSetIterable#close()} when you are done iterating. * * @param resultSetHandler ResultSetHandler * @return iterable results */ public <T> ResultSetIterable<T> executeAndFetchLazy(final ResultSetHandler<T> resultSetHandler) { final ResultSetHandlerFactory<T> factory = newResultSetHandlerFactory(resultSetHandler); return executeAndFetchLazy(factory); }
/** * Read a collection lazily. Generally speaking, this should only be used if you are reading MANY * results and keeping them all in a Collection would cause memory issues. You MUST call * {@link org.sql2o.ResultSetIterable#close()} when you are done iterating. * * @param returnType type of each row * @return iterable results */ public <T> ResultSetIterable<T> executeAndFetchLazy(final Class<T> returnType) { final ResultSetHandlerFactory<T> resultSetHandlerFactory = newResultSetHandlerFactory(returnType); return executeAndFetchLazy(resultSetHandlerFactory); }
public <T> T executeAndFetchFirst(ResultSetHandlerFactory<T> resultSetHandlerFactory){ try (ResultSetIterable<T> iterable = executeAndFetchLazy(resultSetHandlerFactory)) { Iterator<T> iterator = iterable.iterator(); return iterator.hasNext() ? iterator.next() : null; } }