Search in sources :

Example 1 with SQLCustomQuery

use of org.hibernate.loader.custom.sql.SQLCustomQuery in project hibernate-reactive by hibernate.

the class ReactiveStatelessSessionImpl method executeReactiveUpdate.

@Override
public CompletionStage<Integer> executeReactiveUpdate(NativeSQLQuerySpecification specification, QueryParameters parameters) {
    checkOpen();
    parameters.validateParameters();
    // getNativeQueryPlan( specification );
    ReactiveNativeSQLQueryPlan reactivePlan = new ReactiveNativeSQLQueryPlan(specification.getQueryString(), new SQLCustomQuery(specification.getQueryString(), specification.getQueryReturns(), specification.getQuerySpaces(), getFactory()));
    return reactivePlan.performExecuteReactiveUpdate(parameters, this).whenComplete((count, x) -> {
        getPersistenceContext().clear();
        afterOperation(x == null);
    });
}
Also used : SQLCustomQuery(org.hibernate.loader.custom.sql.SQLCustomQuery)

Example 2 with SQLCustomQuery

use of org.hibernate.loader.custom.sql.SQLCustomQuery in project hibernate-reactive by hibernate.

the class ReactiveSessionImpl method executeReactiveUpdate.

@Override
public CompletionStage<Integer> executeReactiveUpdate(NativeSQLQuerySpecification specification, QueryParameters parameters) {
    checkOpenOrWaitingForAutoClose();
    pulseTransactionCoordinator();
    parameters.validateParameters();
    // getNativeQueryPlan( specification );
    ReactiveNativeSQLQueryPlan reactivePlan = new ReactiveNativeSQLQueryPlan(specification.getQueryString(), new SQLCustomQuery(specification.getQueryString(), specification.getQueryReturns(), specification.getQuerySpaces(), getFactory()));
    return reactiveAutoFlushIfRequired(reactivePlan.getCustomQuery().getQuerySpaces()).thenCompose(v -> reactivePlan.performExecuteReactiveUpdate(parameters, this)).whenComplete((count, x) -> {
        afterOperation(x == null);
        delayedAfterCompletion();
    });
}
Also used : CompletionStages.completedFuture(org.hibernate.reactive.util.impl.CompletionStages.completedFuture) BatchingConnection(org.hibernate.reactive.pool.BatchingConnection) NamedQueryDefinition(org.hibernate.engine.spi.NamedQueryDefinition) ExceptionConverter(org.hibernate.engine.spi.ExceptionConverter) NativeQueryTupleTransformer(org.hibernate.jpa.spi.NativeQueryTupleTransformer) EventSource(org.hibernate.event.spi.EventSource) Log(org.hibernate.reactive.logging.impl.Log) CompletionStages.returnNullorRethrow(org.hibernate.reactive.util.impl.CompletionStages.returnNullorRethrow) PersistenceContext(org.hibernate.engine.spi.PersistenceContext) LoggerFactory(org.hibernate.reactive.logging.impl.LoggerFactory) InitializeCollectionEvent(org.hibernate.event.spi.InitializeCollectionEvent) ReactivePersistEventListener(org.hibernate.reactive.event.ReactivePersistEventListener) MergeContext(org.hibernate.event.internal.MergeContext) SQLCustomQuery(org.hibernate.loader.custom.sql.SQLCustomQuery) Map(java.util.Map) HQLQueryPlan(org.hibernate.engine.query.spi.HQLQueryPlan) InternalStateAssertions.assertUseOnEventLoop(org.hibernate.reactive.common.InternalStateAssertions.assertUseOnEventLoop) CompletionStages.voidFuture(org.hibernate.reactive.util.impl.CompletionStages.voidFuture) ResolveNaturalIdEvent(org.hibernate.event.spi.ResolveNaturalIdEvent) LockOptions(org.hibernate.LockOptions) MethodHandles(java.lang.invoke.MethodHandles) FlushEvent(org.hibernate.event.spi.FlushEvent) Set(java.util.Set) RefreshEvent(org.hibernate.event.spi.RefreshEvent) ResultSetMapping(org.hibernate.reactive.common.ResultSetMapping) CacheMode(org.hibernate.CacheMode) Serializable(java.io.Serializable) CompletionStage(java.util.concurrent.CompletionStage) Dialect(org.hibernate.dialect.Dialect) ObjectNotFoundException(org.hibernate.ObjectNotFoundException) AutoFlushEvent(org.hibernate.event.spi.AutoFlushEvent) ReactiveEntityPersister(org.hibernate.reactive.persister.entity.impl.ReactiveEntityPersister) HibernateException(org.hibernate.HibernateException) CompletionStages(org.hibernate.reactive.util.impl.CompletionStages) TypeMismatchException(org.hibernate.TypeMismatchException) RootGraph(org.hibernate.graph.RootGraph) SessionUtil.checkEntityFound(org.hibernate.reactive.session.impl.SessionUtil.checkEntityFound) Supplier(java.util.function.Supplier) RootGraphImplementor(org.hibernate.graph.spi.RootGraphImplementor) ReactiveResolveNaturalIdEventListener(org.hibernate.reactive.event.ReactiveResolveNaturalIdEventListener) IdentitySet(org.hibernate.internal.util.collections.IdentitySet) Status(org.hibernate.engine.spi.Status) ReactiveSession(org.hibernate.reactive.session.ReactiveSession) Tuple(javax.persistence.Tuple) ReactiveFlushEventListener(org.hibernate.reactive.event.ReactiveFlushEventListener) CompletionStages.rethrow(org.hibernate.reactive.util.impl.CompletionStages.rethrow) EntityKey(org.hibernate.engine.spi.EntityKey) CriteriaQueryOptions(org.hibernate.reactive.session.CriteriaQueryOptions) ReactiveMergeEventListener(org.hibernate.reactive.event.ReactiveMergeEventListener) StatefulPersistenceContext(org.hibernate.engine.internal.StatefulPersistenceContext) SessionImpl(org.hibernate.internal.SessionImpl) SessionCreationOptions(org.hibernate.internal.SessionCreationOptions) ReactiveDeleteEventListener(org.hibernate.reactive.event.ReactiveDeleteEventListener) EffectiveEntityGraph(org.hibernate.engine.spi.EffectiveEntityGraph) NativeSQLQuerySpecification(org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification) LoadEvent(org.hibernate.event.spi.LoadEvent) ReactiveConnection(org.hibernate.reactive.pool.ReactiveConnection) EntityPersister(org.hibernate.persister.entity.EntityPersister) GraphSemantic(org.hibernate.graph.GraphSemantic) MessageHelper(org.hibernate.pretty.MessageHelper) MergeEvent(org.hibernate.event.spi.MergeEvent) DefaultReactiveAutoFlushEventListener(org.hibernate.reactive.event.impl.DefaultReactiveAutoFlushEventListener) PersistentCollection(org.hibernate.collection.spi.PersistentCollection) ObjectDeletedException(org.hibernate.ObjectDeletedException) ReactiveCustomLoader(org.hibernate.reactive.loader.custom.impl.ReactiveCustomLoader) HibernateProxy(org.hibernate.proxy.HibernateProxy) JDBCException(org.hibernate.JDBCException) LockEvent(org.hibernate.event.spi.LockEvent) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) ReactiveNativeQuery(org.hibernate.reactive.session.ReactiveNativeQuery) EntityGraph(javax.persistence.EntityGraph) ParameterMetadata(org.hibernate.query.ParameterMetadata) Attribute(javax.persistence.metamodel.Attribute) CompletionException(java.util.concurrent.CompletionException) LoadEventListener(org.hibernate.event.spi.LoadEventListener) List(java.util.List) ReactiveLockEventListener(org.hibernate.reactive.event.ReactiveLockEventListener) ReactiveRefreshEventListener(org.hibernate.reactive.event.ReactiveRefreshEventListener) MappingException(org.hibernate.MappingException) SessionImplementor(org.hibernate.engine.spi.SessionImplementor) ReactiveLoadEventListener(org.hibernate.reactive.event.ReactiveLoadEventListener) Criteria(org.hibernate.reactive.session.Criteria) ReactiveActionQueue(org.hibernate.reactive.engine.ReactiveActionQueue) NamedSQLQueryDefinition(org.hibernate.engine.spi.NamedSQLQueryDefinition) INVALID_NATURAL_ID_REFERENCE(org.hibernate.engine.spi.PersistenceContext.NaturalIdHelper.INVALID_NATURAL_ID_REFERENCE) PersistEvent(org.hibernate.event.spi.PersistEvent) InternalStateAssertions(org.hibernate.reactive.common.InternalStateAssertions) UnresolvableObjectException(org.hibernate.UnresolvableObjectException) CriteriaQueryTupleTransformer(org.hibernate.jpa.spi.CriteriaQueryTupleTransformer) MultiLoadOptions(org.hibernate.persister.entity.MultiLoadOptions) ReactiveQuery(org.hibernate.reactive.session.ReactiveQuery) EntityNotFoundException(javax.persistence.EntityNotFoundException) BulkOperationCleanupAction(org.hibernate.action.internal.BulkOperationCleanupAction) DeleteEvent(org.hibernate.event.spi.DeleteEvent) QueryParameters(org.hibernate.engine.spi.QueryParameters) LockMode(org.hibernate.LockMode) LazyInitializer(org.hibernate.proxy.LazyInitializer) FlushMode(org.hibernate.FlushMode) CompletionStages.returnOrRethrow(org.hibernate.reactive.util.impl.CompletionStages.returnOrRethrow) ReactivePersistenceContextAdapter(org.hibernate.reactive.engine.impl.ReactivePersistenceContextAdapter) DefaultReactiveInitializeCollectionEventListener(org.hibernate.reactive.event.impl.DefaultReactiveInitializeCollectionEventListener) EntityEntry(org.hibernate.engine.spi.EntityEntry) SQLCustomQuery(org.hibernate.loader.custom.sql.SQLCustomQuery)

Aggregations

Serializable (java.io.Serializable)1 MethodHandles (java.lang.invoke.MethodHandles)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 CompletionException (java.util.concurrent.CompletionException)1 CompletionStage (java.util.concurrent.CompletionStage)1 Supplier (java.util.function.Supplier)1 EntityGraph (javax.persistence.EntityGraph)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 Tuple (javax.persistence.Tuple)1 Attribute (javax.persistence.metamodel.Attribute)1 CacheMode (org.hibernate.CacheMode)1 FlushMode (org.hibernate.FlushMode)1 HibernateException (org.hibernate.HibernateException)1 JDBCException (org.hibernate.JDBCException)1 LockMode (org.hibernate.LockMode)1 LockOptions (org.hibernate.LockOptions)1 MappingException (org.hibernate.MappingException)1 ObjectDeletedException (org.hibernate.ObjectDeletedException)1