Search in sources :

Example 1 with NativeQueryTupleTransformer

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

the class AbstractSharedSessionContract method createNativeQuery.

@SuppressWarnings({ "WeakerAccess", "unchecked" })
protected <T> NativeQueryImplementor createNativeQuery(NamedSQLQueryDefinition queryDefinition, Class<T> resultType) {
    if (resultType != null && !Tuple.class.equals(resultType)) {
        resultClassChecking(resultType, queryDefinition);
    }
    final NativeQueryImpl query = new NativeQueryImpl(queryDefinition, this, factory.getQueryPlanCache().getSQLParameterMetadata(queryDefinition.getQueryString(), false));
    if (Tuple.class.equals(resultType)) {
        query.setResultTransformer(new NativeQueryTupleTransformer());
    }
    query.setHibernateFlushMode(queryDefinition.getFlushMode());
    query.setComment(queryDefinition.getComment() != null ? queryDefinition.getComment() : queryDefinition.getName());
    if (queryDefinition.getLockOptions() != null) {
        query.setLockOptions(queryDefinition.getLockOptions());
    }
    initQueryFromNamedDefinition(query, queryDefinition);
    applyQuerySettingsAndHints(query);
    return query;
}
Also used : NativeQueryTupleTransformer(org.hibernate.jpa.spi.NativeQueryTupleTransformer) NativeQueryImpl(org.hibernate.query.internal.NativeQueryImpl)

Example 2 with NativeQueryTupleTransformer

use of org.hibernate.jpa.spi.NativeQueryTupleTransformer in project hibernate-reactive by hibernate.

the class ReactiveSessionImpl method createReactiveNativeQuery.

private <T> ReactiveNativeQuery<T> createReactiveNativeQuery(NamedSQLQueryDefinition queryDefinition, Class<T> resultType) {
    if (resultType != null && !Tuple.class.equals(resultType) && !Object[].class.equals(resultType)) {
        resultClassChecking(resultType, queryDefinition);
    }
    ReactiveNativeQueryImpl<T> query = new ReactiveNativeQueryImpl<>(queryDefinition, this, getFactory().getQueryPlanCache().getSQLParameterMetadata(queryDefinition.getQueryString(), false));
    if (Tuple.class.equals(resultType)) {
        query.setResultTransformer(new NativeQueryTupleTransformer());
    }
    applyQuerySettingsAndHints(query);
    query.setHibernateFlushMode(queryDefinition.getFlushMode());
    query.setComment(comment(queryDefinition));
    if (queryDefinition.getLockOptions() != null) {
        query.setLockOptions(queryDefinition.getLockOptions());
    }
    initQueryFromNamedDefinition(query, queryDefinition);
    return query;
}
Also used : NativeQueryTupleTransformer(org.hibernate.jpa.spi.NativeQueryTupleTransformer) Tuple(javax.persistence.Tuple)

Example 3 with NativeQueryTupleTransformer

use of org.hibernate.jpa.spi.NativeQueryTupleTransformer in project hibernate-reactive by hibernate.

the class ReactiveStatelessSessionImpl method createReactiveNativeQuery.

// TODO fix nasty copy/paste
private <T> ReactiveNativeQuery<T> createReactiveNativeQuery(NamedSQLQueryDefinition queryDefinition, Class<T> resultType) {
    if (resultType != null && !Tuple.class.equals(resultType) && !Object[].class.equals(resultType)) {
        resultClassChecking(resultType, queryDefinition);
    }
    ReactiveNativeQueryImpl<T> query = new ReactiveNativeQueryImpl<>(queryDefinition, this, getFactory().getQueryPlanCache().getSQLParameterMetadata(queryDefinition.getQueryString(), false));
    if (Tuple.class.equals(resultType)) {
        query.setResultTransformer(new NativeQueryTupleTransformer());
    }
    applyQuerySettingsAndHints(query);
    query.setHibernateFlushMode(queryDefinition.getFlushMode());
    query.setComment(comment(queryDefinition));
    if (queryDefinition.getLockOptions() != null) {
        query.setLockOptions(queryDefinition.getLockOptions());
    }
    initQueryFromNamedDefinition(query, queryDefinition);
    return query;
}
Also used : NativeQueryTupleTransformer(org.hibernate.jpa.spi.NativeQueryTupleTransformer) Tuple(javax.persistence.Tuple)

Aggregations

NativeQueryTupleTransformer (org.hibernate.jpa.spi.NativeQueryTupleTransformer)3 Tuple (javax.persistence.Tuple)2 NativeQueryImpl (org.hibernate.query.internal.NativeQueryImpl)1