io.ebeaninternal.server.query.CQueryIteratorSimple Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.query;
import io.ebean.QueryIterator;
import io.ebeaninternal.server.core.OrmQueryRequest;
import javax.persistence.PersistenceException;
import java.sql.SQLException;
/**
* QueryIterator that does not require a buffer for secondary queries.
*/
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 {
request.flushPersistenceContextOnIterate();
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();
}
}
@Override
public void remove() {
throw new PersistenceException("Remove not allowed");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy