use of org.hibernate.hql.internal.HolderInstantiator 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());
}
}
use of org.hibernate.hql.internal.HolderInstantiator in project hibernate-orm by hibernate.
the class CustomLoader method getResultList.
@Override
@SuppressWarnings("unchecked")
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
// meant to handle dynamic instantiation queries...(Copy from QueryLoader)
HolderInstantiator holderInstantiator = HolderInstantiator.getHolderInstantiator(null, resultTransformer, getReturnAliasesForTransformer());
if (holderInstantiator.isRequired()) {
for (int i = 0; i < results.size(); i++) {
Object[] row = (Object[]) results.get(i);
Object result = holderInstantiator.instantiate(row);
results.set(i, result);
}
return resultTransformer.transformList(results);
} else {
return results;
}
}
use of org.hibernate.hql.internal.HolderInstantiator in project hibernate-orm by hibernate.
the class QueryLoader method getResultList.
@SuppressWarnings("unchecked")
@Override
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
// meant to handle dynamic instantiation queries...
HolderInstantiator holderInstantiator = buildHolderInstantiator(resultTransformer);
if (holderInstantiator.isRequired()) {
for (int i = 0; i < results.size(); i++) {
Object[] row = (Object[]) results.get(i);
Object result = holderInstantiator.instantiate(row);
results.set(i, result);
}
if (!hasSelectNew() && resultTransformer != null) {
return resultTransformer.transformList(results);
} else {
return results;
}
} else {
return results;
}
}
Aggregations