All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.query.CQueryIteratorSimple Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.query;

import io.ebean.QueryIterator;
import io.ebeaninternal.server.core.OrmQueryRequest;

import java.sql.SQLException;

/**
 * QueryIterator that does not require a buffer for secondary queries.
 */
final class CQueryIteratorSimple implements QueryIterator {

  private final CQuery cquery;
  private final OrmQueryRequest request;
  private boolean closed;

  CQueryIteratorSimple(CQuery cquery, OrmQueryRequest request) {
    this.cquery = cquery;
    this.request = request;
  }

  @Override
  public boolean hasNext() {
    boolean ret = false;
    try {
      ret = cquery.hasNext();
      return ret;
    } catch (SQLException e) {
      throw cquery.createPersistenceException(e);
    } finally {
      if (!ret) {
        close();
      }
    }
  }

  @Override
  @SuppressWarnings("unchecked")
  public T next() {
    return (T) cquery.next();
  }

  @Override
  public void close() {
    if (!closed) {
      closed = true;
      cquery.updateExecutionStatisticsIterator();
      cquery.close();
      request.endTransIfRequired();
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy