use of org.hibernate.internal.IteratorImpl in project hibernate-orm by hibernate.
the class QueryLoader method iterate.
public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException {
checkQuery(queryParameters);
final boolean stats = session.getFactory().getStatistics().isStatisticsEnabled();
long startTime = 0;
if (stats) {
startTime = System.nanoTime();
}
try {
if (queryParameters.isCallable()) {
throw new QueryException("iterate() not supported for callable statements");
}
final SqlStatementWrapper wrapper = executeQueryStatement(queryParameters, false, Collections.emptyList(), session);
final ResultSet rs = wrapper.getResultSet();
final PreparedStatement st = (PreparedStatement) wrapper.getStatement();
final Iterator result = new IteratorImpl(rs, st, session, queryParameters.isReadOnly(session), queryReturnTypes, queryTranslator.getColumnNames(), buildHolderInstantiator(queryParameters.getResultTransformer()));
if (stats) {
final long endTime = System.nanoTime();
final long milliseconds = TimeUnit.MILLISECONDS.convert(endTime - startTime, TimeUnit.NANOSECONDS);
session.getFactory().getStatistics().queryExecuted(// "HQL: " + queryTranslator.getQueryString(),
getQueryIdentifier(), 0, milliseconds);
}
return result;
} catch (SQLException sqle) {
throw session.getJdbcServices().getSqlExceptionHelper().convert(sqle, "could not execute query using iterate", getSQLString());
}
}
use of org.hibernate.internal.IteratorImpl in project hibernate-orm by hibernate.
the class QueryTranslatorImpl method iterate.
/**
* Return the query results as an iterator
*/
@Override
public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException {
boolean stats = session.getFactory().getStatistics().isStatisticsEnabled();
long startTime = 0;
if (stats) {
startTime = System.nanoTime();
}
try {
final List<AfterLoadAction> afterLoadActions = new ArrayList<AfterLoadAction>();
final SqlStatementWrapper wrapper = executeQueryStatement(queryParameters, false, afterLoadActions, session);
final ResultSet rs = wrapper.getResultSet();
final PreparedStatement st = (PreparedStatement) wrapper.getStatement();
HolderInstantiator hi = HolderInstantiator.createClassicHolderInstantiator(holderConstructor, queryParameters.getResultTransformer());
Iterator result = new IteratorImpl(rs, st, session, queryParameters.isReadOnly(session), returnTypes, getColumnNames(), hi);
if (stats) {
final long endTime = System.nanoTime();
final long milliseconds = TimeUnit.MILLISECONDS.convert(endTime - startTime, TimeUnit.NANOSECONDS);
session.getFactory().getStatistics().queryExecuted("HQL: " + queryString, 0, milliseconds);
}
return result;
} catch (SQLException sqle) {
throw getFactory().getJdbcServices().getSqlExceptionHelper().convert(sqle, "could not execute query using iterate", getSQLString());
}
}
Aggregations