Search in sources :

Example 1 with CriteriaQueryTupleTransformer

use of org.hibernate.jpa.spi.CriteriaQueryTupleTransformer in project hibernate-orm by hibernate.

the class SessionImpl method createQuery.

@Override
@SuppressWarnings("unchecked")
public <T> QueryImplementor<T> createQuery(String jpaqlString, Class<T> resultClass, Selection selection, QueryOptions queryOptions) {
    try {
        final QueryImplementor query = createQuery(jpaqlString);
        if (queryOptions.getValueHandlers() == null) {
            if (queryOptions.getResultMetadataValidator() != null) {
                queryOptions.getResultMetadataValidator().validate(query.getReturnTypes());
            }
        }
        // determine if we need a result transformer
        List tupleElements = Tuple.class.equals(resultClass) ? ((CompoundSelectionImpl<Tuple>) selection).getCompoundSelectionItems() : null;
        if (queryOptions.getValueHandlers() != null || tupleElements != null) {
            query.setResultTransformer(new CriteriaQueryTupleTransformer(queryOptions.getValueHandlers(), tupleElements));
        }
        return query;
    } catch (RuntimeException e) {
        throw exceptionConverter.convert(e);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) QueryImplementor(org.hibernate.query.spi.QueryImplementor) Tuple(javax.persistence.Tuple) CriteriaQueryTupleTransformer(org.hibernate.jpa.spi.CriteriaQueryTupleTransformer)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Tuple (javax.persistence.Tuple)1 CriteriaQueryTupleTransformer (org.hibernate.jpa.spi.CriteriaQueryTupleTransformer)1 QueryImplementor (org.hibernate.query.spi.QueryImplementor)1