use of org.hibernate.jpa.HibernateQuery in project querydsl by querydsl.
the class HibernateHandler method transform.
@Override
public boolean transform(Query query, FactoryExpression<?> projection) {
if (query instanceof HibernateQuery) {
ResultTransformer transformer = new FactoryExpressionTransformer(projection);
((HibernateQuery) query).getHibernateQuery().setResultTransformer(transformer);
return true;
} else {
return false;
}
}
use of org.hibernate.jpa.HibernateQuery in project querydsl by querydsl.
the class HibernateHandler method iterate.
@SuppressWarnings("unchecked")
@Override
public <T> CloseableIterator<T> iterate(Query query, FactoryExpression<?> projection) {
if (query instanceof HibernateQuery) {
HibernateQuery hQuery = (HibernateQuery) query;
ScrollableResults results = hQuery.getHibernateQuery().scroll(ScrollMode.FORWARD_ONLY);
CloseableIterator<T> iterator = new ScrollableResultsIterator<T>(results);
if (projection != null) {
iterator = new TransformingIterator<T>(iterator, projection);
}
return iterator;
} else {
Iterator<T> iterator = query.getResultList().iterator();
if (projection != null) {
return new TransformingIterator<T>(iterator, projection);
} else {
return new IteratorAdapter<T>(iterator);
}
}
}
Aggregations