org.sql2o.Query.executeAndFetchLazy()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中org.sql2o.Query.executeAndFetchLazy方法的一些代码示例,展示了Query.executeAndFetchLazy的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.executeAndFetchLazy方法的具体详情如下:
包路径:org.sql2o.Query
类名称:Query
方法名:executeAndFetchLazy

Query.executeAndFetchLazy介绍

[英]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 org.sql2o.ResultSetIterable#close() when you are done iterating.
[中]懒洋洋地读一本藏书。一般来说,只有当你正在阅读许多结果,并且将它们全部保存在一个集合中会导致内存问题时,才应该使用这个选项。你必须打电话给org。sql2o。迭代完成后,ResultSetTable#close()将自动关闭。

代码示例

代码示例来源:origin: runelite/runelite

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);
}

代码示例来源:origin: aaberg/sql2o

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;
}

代码示例来源:origin: aaberg/sql2o

/**
 * 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);
}

代码示例来源:origin: aaberg/sql2o

public <T> T executeAndFetchFirst(ResultSetHandlerFactory<T> resultSetHandlerFactory){
  try (ResultSetIterable<T> iterable = executeAndFetchLazy(resultSetHandlerFactory))  {
    Iterator<T> iterator = iterable.iterator();
    return iterator.hasNext() ? iterator.next() : null;
  }
}

代码示例来源:origin: aaberg/sql2o

/**
 * 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);
}

代码示例来源:origin: org.sql2o/sql2o

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;
}

代码示例来源:origin: biezhi/anima

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;
}

代码示例来源:origin: biezhi/anima

/**
 * 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);
}

代码示例来源:origin: biezhi/anima

public <T> T executeAndFetchFirst(ResultSetHandlerFactory<T> resultSetHandlerFactory) {
  try (ResultSetIterable<T> iterable = executeAndFetchLazy(resultSetHandlerFactory)) {
    Iterator<T> iterator = iterable.iterator();
    return iterator.hasNext() ? iterator.next() : null;
  }
}

代码示例来源:origin: org.sql2o/sql2o

/**
 * 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);
}

代码示例来源:origin: biezhi/anima

/**
 * 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);
}

代码示例来源:origin: org.sql2o/sql2o

/**
 * 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);
}

代码示例来源:origin: org.sql2o/sql2o

public <T> T executeAndFetchFirst(ResultSetHandlerFactory<T> resultSetHandlerFactory){
  try (ResultSetIterable<T> iterable = executeAndFetchLazy(resultSetHandlerFactory))  {
    Iterator<T> iterator = iterable.iterator();
    return iterator.hasNext() ? iterator.next() : null;
  }
}

相关文章