Class StageStatelessSessionImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletionStage<java.lang.Void> close()
      Close the reactive session and release the underlying database connection.
      <T> jakarta.persistence.EntityGraph<T> createEntityGraph​(java.lang.Class<T> rootType)
      Create a new mutable EntityGraph
      <T> jakarta.persistence.EntityGraph<T> createEntityGraph​(java.lang.Class<T> rootType, java.lang.String graphName)
      Create a new mutable copy of a named EntityGraph
      <R> Stage.Query<R> createNamedQuery​(java.lang.String queryName)
      Create an instance of Stage.Query for the named query.
      <R> Stage.SelectionQuery<R> createNamedQuery​(java.lang.String queryName, java.lang.Class<R> resultType)
      Create an instance of Stage.Query for the named query.
      <R> Stage.Query<R> createNativeQuery​(java.lang.String queryString)
      Create an instance of Stage.Query for the given SQL query string, or SQL update, insert, or delete statement.
      <R> Stage.SelectionQuery<R> createNativeQuery​(java.lang.String queryString, java.lang.Class<R> resultType)
      Create an instance of Stage.Query for the given SQL query string, using the given resultType to interpret the results.
      <R> Stage.MutationQuery createQuery​(jakarta.persistence.criteria.CriteriaDelete<R> criteriaDelete)
      Create an instance of Stage.MutationQuery for the given criteria delete.
      <R> Stage.SelectionQuery<R> createQuery​(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery)
      Create an instance of Stage.SelectionQuery for the given criteria query.
      <R> Stage.MutationQuery createQuery​(jakarta.persistence.criteria.CriteriaUpdate<R> criteriaUpdate)
      Create an instance of Stage.MutationQuery for the given criteria update.
      <R> Stage.Query<R> createQuery​(java.lang.String queryString)
      Create an instance of Stage.Query for the given HQL/JPQL query string or HQL/JPQL update or delete statement.
      <R> Stage.SelectionQuery<R> createQuery​(java.lang.String queryString, java.lang.Class<R> resultType)
      Create an instance of Stage.SelectionQuery for the given HQL/JPQL query string and query result type.
      Stage.Transaction currentTransaction()
      Obtain the transaction currently associated with this session, if any.
      java.util.concurrent.CompletionStage<java.lang.Void> delete​(int batchSize, java.lang.Object... entities)
      Delete multiple rows.
      java.util.concurrent.CompletionStage<java.lang.Void> delete​(java.lang.Object entity)
      Delete a row.
      java.util.concurrent.CompletionStage<java.lang.Void> delete​(java.lang.Object... entities)
      Delete multiple rows.
      <T> java.util.concurrent.CompletionStage<T> fetch​(T association)
      Asynchronously fetch an association that's configured for lazy loading.
      <T> java.util.concurrent.CompletionStage<T> get​(jakarta.persistence.EntityGraph<T> entityGraph, java.lang.Object id)
      Retrieve a row, using the given EntityGraph as a fetch plan.
      <T> java.util.concurrent.CompletionStage<T> get​(java.lang.Class<T> entityClass, java.lang.Object id)
      Retrieve a row.
      <T> java.util.concurrent.CompletionStage<T> get​(java.lang.Class<T> entityClass, java.lang.Object id, org.hibernate.LockMode lockMode)
      Retrieve a row, obtaining the specified lock mode.
      <T> jakarta.persistence.EntityGraph<T> getEntityGraph​(java.lang.Class<T> rootType, java.lang.String graphName)
      Obtain a named EntityGraph
      ReactiveConnection getReactiveConnection()  
      <T> ResultSetMapping<T> getResultSetMapping​(java.lang.Class<T> resultType, java.lang.String mappingName)
      Obtain a native SQL result set mapping defined via the annotation SqlResultSetMapping.
      java.util.concurrent.CompletionStage<java.lang.Void> insert​(int batchSize, java.lang.Object... entities)
      Insert multiple rows.
      java.util.concurrent.CompletionStage<java.lang.Void> insert​(java.lang.Object entity)
      Insert a row.
      java.util.concurrent.CompletionStage<java.lang.Void> insert​(java.lang.Object... entities)
      Insert multiple rows.
      boolean isOpen()  
      java.util.concurrent.CompletionStage<java.lang.Void> refresh​(int batchSize, java.lang.Object... entities)
      Refresh the entity instance state from the database.
      java.util.concurrent.CompletionStage<java.lang.Void> refresh​(java.lang.Object entity)
      Refresh the entity instance state from the database.
      java.util.concurrent.CompletionStage<java.lang.Void> refresh​(java.lang.Object... entities)
      Refresh the entity instance state from the database.
      java.util.concurrent.CompletionStage<java.lang.Void> refresh​(java.lang.Object entity, org.hibernate.LockMode lockMode)
      Refresh the entity instance state from the database.
      java.util.concurrent.CompletionStage<java.lang.Void> update​(int batchSize, java.lang.Object... entities)
      Update multiple rows.
      java.util.concurrent.CompletionStage<java.lang.Void> update​(java.lang.Object entity)
      Update a row.
      java.util.concurrent.CompletionStage<java.lang.Void> update​(java.lang.Object... entities)
      Update multiple rows.
      <T> java.util.concurrent.CompletionStage<T> withTransaction​(java.util.function.Function<Stage.Transaction,​java.util.concurrent.CompletionStage<T>> work)
      Performs the given work within the scope of a database transaction, automatically flushing the session.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • get

        public <T> java.util.concurrent.CompletionStage<T> get​(java.lang.Class<T> entityClass,
                                                               java.lang.Object id)
        Description copied from interface: Stage.StatelessSession
        Retrieve a row.
        Specified by:
        get in interface Stage.StatelessSession
        Parameters:
        entityClass - The class of the entity to retrieve
        id - The id of the entity to retrieve
        Returns:
        a detached entity instance, via a CompletionStage
        See Also:
        StatelessSession.get(Class, Object)
      • get

        public <T> java.util.concurrent.CompletionStage<T> get​(java.lang.Class<T> entityClass,
                                                               java.lang.Object id,
                                                               org.hibernate.LockMode lockMode)
        Description copied from interface: Stage.StatelessSession
        Retrieve a row, obtaining the specified lock mode.
        Specified by:
        get in interface Stage.StatelessSession
        Parameters:
        entityClass - The class of the entity to retrieve
        id - The id of the entity to retrieve
        lockMode - The lock mode to apply to the entity
        Returns:
        a detached entity instance, via a CompletionStage
        See Also:
        StatelessSession.get(Class, Object, LockMode)
      • insert

        public java.util.concurrent.CompletionStage<java.lang.Void> insert​(java.lang.Object entity)
        Description copied from interface: Stage.StatelessSession
        Insert a row.
        Specified by:
        insert in interface Stage.StatelessSession
        Parameters:
        entity - a new transient instance
        See Also:
        StatelessSession.insert(Object)
      • insert

        public java.util.concurrent.CompletionStage<java.lang.Void> insert​(java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Insert multiple rows.
        Specified by:
        insert in interface Stage.StatelessSession
        Parameters:
        entities - new transient instances
        See Also:
        StatelessSession.insert(Object)
      • insert

        public java.util.concurrent.CompletionStage<java.lang.Void> insert​(int batchSize,
                                                                           java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Insert multiple rows.
        Specified by:
        insert in interface Stage.StatelessSession
        Parameters:
        batchSize - the batch size
        entities - new transient instances
        See Also:
        StatelessSession.insert(Object)
      • delete

        public java.util.concurrent.CompletionStage<java.lang.Void> delete​(java.lang.Object entity)
        Description copied from interface: Stage.StatelessSession
        Delete a row.
        Specified by:
        delete in interface Stage.StatelessSession
        Parameters:
        entity - a detached entity instance
        See Also:
        StatelessSession.delete(Object)
      • delete

        public java.util.concurrent.CompletionStage<java.lang.Void> delete​(java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Delete multiple rows.
        Specified by:
        delete in interface Stage.StatelessSession
        Parameters:
        entities - detached entity instances
        See Also:
        StatelessSession.delete(Object)
      • delete

        public java.util.concurrent.CompletionStage<java.lang.Void> delete​(int batchSize,
                                                                           java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Delete multiple rows.
        Specified by:
        delete in interface Stage.StatelessSession
        Parameters:
        batchSize - the batch size
        entities - detached entity instances
        See Also:
        StatelessSession.delete(Object)
      • update

        public java.util.concurrent.CompletionStage<java.lang.Void> update​(java.lang.Object entity)
        Description copied from interface: Stage.StatelessSession
        Update a row.
        Specified by:
        update in interface Stage.StatelessSession
        Parameters:
        entity - a detached entity instance
        See Also:
        StatelessSession.update(Object)
      • update

        public java.util.concurrent.CompletionStage<java.lang.Void> update​(java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Update multiple rows.
        Specified by:
        update in interface Stage.StatelessSession
        Parameters:
        entities - a detached entity instance
        See Also:
        StatelessSession.update(Object)
      • update

        public java.util.concurrent.CompletionStage<java.lang.Void> update​(int batchSize,
                                                                           java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Update multiple rows.
        Specified by:
        update in interface Stage.StatelessSession
        Parameters:
        batchSize - the batch size
        entities - a detached entity instance
        See Also:
        StatelessSession.update(Object)
      • refresh

        public java.util.concurrent.CompletionStage<java.lang.Void> refresh​(java.lang.Object entity)
        Description copied from interface: Stage.StatelessSession
        Refresh the entity instance state from the database.
        Specified by:
        refresh in interface Stage.StatelessSession
        Parameters:
        entity - The entity to be refreshed.
        See Also:
        StatelessSession.refresh(Object)
      • refresh

        public java.util.concurrent.CompletionStage<java.lang.Void> refresh​(java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Refresh the entity instance state from the database.
        Specified by:
        refresh in interface Stage.StatelessSession
        Parameters:
        entities - The entities to be refreshed.
        See Also:
        StatelessSession.refresh(Object)
      • refresh

        public java.util.concurrent.CompletionStage<java.lang.Void> refresh​(int batchSize,
                                                                            java.lang.Object... entities)
        Description copied from interface: Stage.StatelessSession
        Refresh the entity instance state from the database.
        Specified by:
        refresh in interface Stage.StatelessSession
        Parameters:
        batchSize - the batch size
        entities - The entities to be refreshed.
        See Also:
        StatelessSession.refresh(Object)
      • refresh

        public java.util.concurrent.CompletionStage<java.lang.Void> refresh​(java.lang.Object entity,
                                                                            org.hibernate.LockMode lockMode)
        Description copied from interface: Stage.StatelessSession
        Refresh the entity instance state from the database.
        Specified by:
        refresh in interface Stage.StatelessSession
        Parameters:
        entity - The entity to be refreshed.
        lockMode - The LockMode to be applied.
        See Also:
        StatelessSession.refresh(Object, LockMode)
      • fetch

        public <T> java.util.concurrent.CompletionStage<T> fetch​(T association)
        Description copied from interface: Stage.StatelessSession
        Asynchronously fetch an association that's configured for lazy loading.
         session.fetch(author.getBook()).thenAccept(book -> print(book.getTitle()))
         
        Warning: this operation in a stateless session is quite sensitive to data aliasing effects and should be used with great care.
        Specified by:
        fetch in interface Stage.StatelessSession
        Parameters:
        association - a lazy-loaded association
        Returns:
        the fetched association, via a CompletionStage
        See Also:
        Hibernate.initialize(Object)
      • withTransaction

        public <T> java.util.concurrent.CompletionStage<T> withTransaction​(java.util.function.Function<Stage.Transaction,​java.util.concurrent.CompletionStage<T>> work)
        Description copied from interface: Stage.StatelessSession
        Performs the given work within the scope of a database transaction, automatically flushing the session. The transaction will be rolled back if the work completes with an uncaught exception, or if Stage.Transaction.markForRollback() is called.
      • If there is already a transaction associated with this session, the work is executed in the context of the existing transaction, and no new transaction is initiated.
      • If there is no transaction associated with this session, a new transaction is started, and the work is executed in the context of the new transaction.
Specified by:
withTransaction in interface Stage.StatelessSession
Parameters:
work - a function which accepts Stage.Transaction and returns the result of the work as a CompletionStage.
See Also:
Stage.SessionFactory.withTransaction(BiFunction)