Search in sources :

Example 1 with QuerySqmImpl

use of org.hibernate.query.sqm.internal.QuerySqmImpl in project hibernate-orm by hibernate.

the class AbstractSharedSessionContract method createQuery.

@Override
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> resultClass) {
    checkOpen();
    pulseTransactionCoordinator();
    delayedAfterCompletion();
    try {
        final QueryEngine queryEngine = getFactory().getQueryEngine();
        final QueryInterpretationCache interpretationCache = queryEngine.getInterpretationCache();
        final QuerySqmImpl<T> query = new QuerySqmImpl<>(queryString, interpretationCache.resolveHqlInterpretation(queryString, s -> queryEngine.getHqlTranslator().translate(queryString)), resultClass, this);
        applyQuerySettingsAndHints(query);
        query.setComment(queryString);
        return query;
    } catch (RuntimeException e) {
        markForRollbackOnly();
        throw getExceptionConverter().convert(e);
    }
}
Also used : QuerySqmImpl(org.hibernate.query.sqm.internal.QuerySqmImpl) NamedCallableQueryMemento(org.hibernate.procedure.spi.NamedCallableQueryMemento) TransactionImplementor(org.hibernate.engine.transaction.spi.TransactionImplementor) EntityPersister(org.hibernate.persister.entity.EntityPersister) MutationQuery(org.hibernate.query.MutationQuery) ExceptionConverter(org.hibernate.engine.spi.ExceptionConverter) NativeQueryTupleTransformer(org.hibernate.jpa.spi.NativeQueryTupleTransformer) NamedObjectRepository(org.hibernate.query.named.NamedObjectRepository) StandardRandomStrategy(org.hibernate.id.uuid.StandardRandomStrategy) HibernateCriteriaBuilder(org.hibernate.query.criteria.HibernateCriteriaBuilder) ObjectInputStream(java.io.ObjectInputStream) CriteriaDelete(jakarta.persistence.criteria.CriteriaDelete) Interceptor(org.hibernate.Interceptor) CriteriaUpdate(jakarta.persistence.criteria.CriteriaUpdate) UnknownNamedQueryException(org.hibernate.query.UnknownNamedQueryException) JtaTransactionCoordinatorImpl(org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl) SqmDmlStatement(org.hibernate.query.sqm.tree.SqmDmlStatement) NamedResultSetMappingMemento(org.hibernate.query.named.NamedResultSetMappingMemento) EntityNameResolver(org.hibernate.EntityNameResolver) Transaction(org.hibernate.Transaction) SqmStatement(org.hibernate.query.sqm.tree.SqmStatement) SqmQueryImplementor(org.hibernate.query.hql.spi.SqmQueryImplementor) SqmUtil(org.hibernate.query.sqm.internal.SqmUtil) Locale(java.util.Locale) SessionEventListenerManager(org.hibernate.engine.spi.SessionEventListenerManager) Query(org.hibernate.query.Query) SqmUpdateStatement(org.hibernate.query.sqm.tree.update.SqmUpdateStatement) HqlInterpretation(org.hibernate.query.spi.HqlInterpretation) FlushModeTypeHelper(org.hibernate.jpa.internal.util.FlushModeTypeHelper) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) SqmDeleteStatement(org.hibernate.query.sqm.tree.delete.SqmDeleteStatement) JdbcCoordinator(org.hibernate.engine.jdbc.spi.JdbcCoordinator) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) PhysicalConnectionHandlingMode(org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode) TimeZone(java.util.TimeZone) FlushModeType(jakarta.persistence.FlushModeType) StringHelper(org.hibernate.internal.util.StringHelper) UUID(java.util.UUID) Tuple(jakarta.persistence.Tuple) EmptyInterceptor(org.hibernate.EmptyInterceptor) WorkExecutorVisitable(org.hibernate.jdbc.WorkExecutorVisitable) QuerySqmImpl(org.hibernate.query.sqm.internal.QuerySqmImpl) SessionException(org.hibernate.SessionException) CacheMode(org.hibernate.CacheMode) List(java.util.List) NativeQueryImplementor(org.hibernate.query.sql.spi.NativeQueryImplementor) QueryTypeMismatchException(org.hibernate.query.QueryTypeMismatchException) HibernateException(org.hibernate.HibernateException) TransactionImpl(org.hibernate.engine.transaction.internal.TransactionImpl) NativeQueryImpl(org.hibernate.query.sql.internal.NativeQueryImpl) StatementInspector(org.hibernate.resource.jdbc.spi.StatementInspector) TRUE(java.lang.Boolean.TRUE) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) JdbcConnectionAccess(org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess) SessionEventListenerManagerImpl(org.hibernate.engine.internal.SessionEventListenerManagerImpl) SessionEventListener(org.hibernate.SessionEventListener) IllegalMutationQueryException(org.hibernate.query.IllegalMutationQueryException) TransactionCoordinator(org.hibernate.resource.transaction.spi.TransactionCoordinator) CacheTransactionSynchronization(org.hibernate.cache.spi.CacheTransactionSynchronization) Function(java.util.function.Function) UnknownEntityTypeException(org.hibernate.UnknownEntityTypeException) SQLException(java.sql.SQLException) SqmSelectionQuery(org.hibernate.query.sqm.SqmSelectionQuery) QueryImplementor(org.hibernate.query.spi.QueryImplementor) SqmQuerySpec(org.hibernate.query.sqm.tree.select.SqmQuerySpec) ObjectOutputStream(java.io.ObjectOutputStream) QueryInterpretationCache(org.hibernate.query.spi.QueryInterpretationCache) NamedSqmQueryMemento(org.hibernate.query.sqm.spi.NamedSqmQueryMemento) ProcedureCall(org.hibernate.procedure.ProcedureCall) LockMode(org.hibernate.LockMode) JdbcCoordinatorImpl(org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl) SqmSelectionQueryImpl(org.hibernate.query.sqm.internal.SqmSelectionQueryImpl) IllegalSelectQueryException(org.hibernate.query.IllegalSelectQueryException) IllegalNamedQueryOptionsException(org.hibernate.query.IllegalNamedQueryOptionsException) IOException(java.io.IOException) FlushMode(org.hibernate.FlushMode) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) EntityKey(org.hibernate.engine.spi.EntityKey) JdbcSessionContext(org.hibernate.resource.jdbc.spi.JdbcSessionContext) TransactionCoordinatorBuilder(org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder) Work(org.hibernate.jdbc.Work) SqmQueryGroup(org.hibernate.query.sqm.tree.select.SqmQueryGroup) QueryEngine(org.hibernate.query.spi.QueryEngine) CriteriaQuery(jakarta.persistence.criteria.CriteriaQuery) ProcedureCallImpl(org.hibernate.procedure.internal.ProcedureCallImpl) LobCreator(org.hibernate.engine.jdbc.LobCreator) NamedNativeQueryMemento(org.hibernate.query.sql.spi.NamedNativeQueryMemento) NamedNativeQuery(jakarta.persistence.NamedNativeQuery) TransactionRequiredException(jakarta.persistence.TransactionRequiredException) ReturningWork(org.hibernate.jdbc.ReturningWork) SelectionQuery(org.hibernate.query.SelectionQuery) QueryInterpretationCache(org.hibernate.query.spi.QueryInterpretationCache) QueryEngine(org.hibernate.query.spi.QueryEngine)

Aggregations

FlushModeType (jakarta.persistence.FlushModeType)1 NamedNativeQuery (jakarta.persistence.NamedNativeQuery)1 TransactionRequiredException (jakarta.persistence.TransactionRequiredException)1 Tuple (jakarta.persistence.Tuple)1 CriteriaDelete (jakarta.persistence.criteria.CriteriaDelete)1 CriteriaQuery (jakarta.persistence.criteria.CriteriaQuery)1 CriteriaUpdate (jakarta.persistence.criteria.CriteriaUpdate)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 TRUE (java.lang.Boolean.TRUE)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 Locale (java.util.Locale)1 TimeZone (java.util.TimeZone)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 CacheMode (org.hibernate.CacheMode)1 EmptyInterceptor (org.hibernate.EmptyInterceptor)1 EntityNameResolver (org.hibernate.EntityNameResolver)1