Class MutinySessionDelegator

java.lang.Object
org.hibernate.reactive.mutiny.delegation.MutinySessionDelegator
All Implemented Interfaces:
Mutiny.Closeable, Mutiny.QueryProducer, Mutiny.Session

public abstract class MutinySessionDelegator extends Object implements Mutiny.Session
Wraps a delegate() session.
  • Constructor Details

    • MutinySessionDelegator

      public MutinySessionDelegator()
  • Method Details

    • delegate

      public abstract Mutiny.Session delegate()
    • find

      public <T> io.smallrye.mutiny.Uni<T> find(Class<T> entityClass, Object id)
      Description copied from interface: Mutiny.Session
      Asynchronously return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return the associated instance. This method never returns an uninitialized instance.
       session.find(Book.class, id).map(book -> print(book.getTitle()));
       
      Specified by:
      find in interface Mutiny.Session
      Parameters:
      entityClass - The entity type
      id - an identifier
      Returns:
      a persistent instance or null via a Uni
      See Also:
      • EntityManager.find(Class, Object)
    • find

      public <T> io.smallrye.mutiny.Uni<T> find(Class<T> entityClass, Object id, jakarta.persistence.LockModeType lockModeType)
      Description copied from interface: Mutiny.Session
      Asynchronously return the persistent instance of the given entity class with the given identifier, requesting the given LockModeType.
      Specified by:
      find in interface Mutiny.Session
      Parameters:
      entityClass - The entity type
      id - an identifier
      lockModeType - the requested LockModeType
      Returns:
      a persistent instance or null via a Uni
      See Also:
    • find

      public <T> io.smallrye.mutiny.Uni<T> find(Class<T> entityClass, Object id, LockMode lockMode)
      Description copied from interface: Mutiny.Session
      Asynchronously return the persistent instance of the given entity class with the given identifier, requesting the given LockMode.
      Specified by:
      find in interface Mutiny.Session
      Parameters:
      entityClass - The entity type
      id - an identifier
      lockMode - the requested LockMode
      Returns:
      a persistent instance or null via a Uni
      See Also:
    • find

      public <T> io.smallrye.mutiny.Uni<T> find(jakarta.persistence.EntityGraph<T> entityGraph, Object id)
      Description copied from interface: Mutiny.Session
      Asynchronously return the persistent instance with the given identifier of an entity class, using the given EntityGraph as a fetch plan.
      Specified by:
      find in interface Mutiny.Session
      Parameters:
      entityGraph - an EntityGraph specifying the entity and associations to be fetched
      id - an identifier
      See Also:
    • find

      public <T> io.smallrye.mutiny.Uni<List<T>> find(Class<T> entityClass, Object... ids)
      Description copied from interface: Mutiny.Session
      Asynchronously return the persistent instances of the given entity class with the given identifiers, or null if there is no such persistent instance.
      Specified by:
      find in interface Mutiny.Session
      Parameters:
      entityClass - The entity type
      ids - the identifiers
      Returns:
      a list of persistent instances and nulls via a Uni
      See Also:
    • createNamedQuery

      public <R> Mutiny.SelectionQuery<R> createNamedQuery(String queryName, Class<R> resultType)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the named query.
      Specified by:
      createNamedQuery in interface Mutiny.QueryProducer
      Parameters:
      queryName - The name of the query
      resultType - the Java type returned in each row of query results
      Returns:
      The Mutiny.SelectionQuery instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String, Class)
    • createQuery

      public <R> Mutiny.SelectionQuery<R> createQuery(String queryString, Class<R> resultType)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given HQL/JPQL query string and query result type.
      Specified by:
      createQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The HQL/JPQL query
      resultType - the Java type returned in each row of query results
      Returns:
      The Mutiny.SelectionQuery instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String, Class)
    • isReadOnly

      public boolean isReadOnly(Object entityOrProxy)
      Description copied from interface: Mutiny.Session
      Is the specified entity or proxy read-only?
      Specified by:
      isReadOnly in interface Mutiny.Session
      See Also:
    • createNativeQuery

      public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, Class<R> resultType, AffectedEntities affectedEntities)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given SQL query string, using the given resultType to interpret the results.
      • If the given result type is Object, or a built-in type such as String or Integer, the result set must have a single column, which will be returned as a scalar.
      • If the given result type is Object[], then the result set must have multiple columns, which will be returned in arrays.
      • Otherwise, the given result type must be an entity class, in which case the result set column aliases must map to the fields of the entity, and the query will return instances of the entity.

      Any affected entities are synchronized with the database before execution of the query.

      Specified by:
      createNativeQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The SQL query
      resultType - the Java type returned in each row of query results
      affectedEntities - The entities which are affected by the query
      Returns:
      The Mutiny.Query instance for manipulation and execution
      See Also:
      • EntityManager.createNativeQuery(String, Class)
    • isDefaultReadOnly

      public boolean isDefaultReadOnly()
      Specified by:
      isDefaultReadOnly in interface Mutiny.Session
      Returns:
      the default read-only mode for entities and proxies loaded in this session
    • unproxy

      public <T> io.smallrye.mutiny.Uni<T> unproxy(T association)
      Description copied from interface: Mutiny.Session
      Asynchronously fetch an association that's configured for lazy loading, and unwrap the underlying entity implementation from any proxy.
       session.unproxy(author.getBook()).thenAccept(book -> print(book.getTitle()));
       
      Specified by:
      unproxy in interface Mutiny.Session
      Parameters:
      association - a lazy-loaded association
      Returns:
      the fetched association, via a Uni
      See Also:
    • createMutationQuery

      public Mutiny.MutationQuery createMutationQuery(String queryString)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.MutationQuery for the given HQL/JPQL update or delete statement.
      Specified by:
      createMutationQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The HQL/JPQL query, update or delete statement
      Returns:
      The Mutiny.MutationQuery instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String)
    • close

      public io.smallrye.mutiny.Uni<Void> close()
      Specified by:
      close in interface Mutiny.Closeable
    • disableFetchProfile

      public Mutiny.Session disableFetchProfile(String name)
      Description copied from interface: Mutiny.Session
      Disable a particular fetch profile on this session, or do nothing if the requested fetch profile is not enabled.
      Specified by:
      disableFetchProfile in interface Mutiny.Session
      Parameters:
      name - The name of the fetch profile to be disabled.
      See Also:
    • getEntityGraph

      public <T> jakarta.persistence.EntityGraph<T> getEntityGraph(Class<T> rootType, String graphName)
      Description copied from interface: Mutiny.QueryProducer
      Obtain a named EntityGraph
      Specified by:
      getEntityGraph in interface Mutiny.QueryProducer
    • createSelectionQuery

      public <R> Mutiny.SelectionQuery<R> createSelectionQuery(String queryString, Class<R> resultType)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given HQL/JPQL query string.
      Specified by:
      createSelectionQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The HQL/JPQL query
      Returns:
      The Mutiny.SelectionQuery instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String, Class)
    • refresh

      public io.smallrye.mutiny.Uni<Void> refresh(Object entity, jakarta.persistence.LockModeType lockModeType)
      Description copied from interface: Mutiny.Session
      Re-read the state of the given instance from the underlying database, requesting the given LockModeType.
      Specified by:
      refresh in interface Mutiny.Session
      Parameters:
      entity - a managed persistent entity instance
      lockModeType - the requested lock mode
      See Also:
    • lock

      public io.smallrye.mutiny.Uni<Void> lock(Object entity, jakarta.persistence.LockModeType lockModeType)
      Description copied from interface: Mutiny.Session
      Obtain the specified lock level upon the given object. For example, this operation may be used to:
      • perform a version check with LockModeType.PESSIMISTIC_READ,
      • upgrade to a pessimistic lock with LockModeType.PESSIMISTIC_WRITE,
      • force a version increment with LockModeType.PESSIMISTIC_FORCE_INCREMENT,
      • schedule a version check just before the end of the transaction with LockModeType.OPTIMISTIC, or
      • schedule a version increment just before the end of the transaction with LockModeType.OPTIMISTIC_FORCE_INCREMENT.

      This operation cascades to associated instances if the association is mapped with CascadeType.LOCK.

      Specified by:
      lock in interface Mutiny.Session
      Parameters:
      entity - a managed persistent instance
      lockModeType - the lock level
    • createQuery

      public <R> Mutiny.Query<R> createQuery(jakarta.persistence.TypedQueryReference<R> typedQueryReference)
      Description copied from interface: Mutiny.QueryProducer
      Create a typed Query instance for the given typed query reference.
      Specified by:
      createQuery in interface Mutiny.QueryProducer
      Parameters:
      typedQueryReference - the type query reference
      Returns:
      The Query instance for execution
      See Also:
    • createNativeQuery

      public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping, AffectedEntities affectedEntities)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given SQL query string, using the given ResultSetMapping to interpret the result set.

      Any affected entities are synchronized with the database before execution of the query.

      Specified by:
      createNativeQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The SQL query
      resultSetMapping - the result set mapping
      affectedEntities - The entities which are affected by the query
      Returns:
      The Mutiny.SelectionQuery instance for manipulation and execution
      See Also:
    • lock

      public io.smallrye.mutiny.Uni<Void> lock(Object entity, LockMode lockMode)
      Description copied from interface: Mutiny.Session
      Obtain the specified lock level upon the given object. For example, this operation may be used to:

      This operation cascades to associated instances if the association is mapped with CascadeType.LOCK.

      Specified by:
      lock in interface Mutiny.Session
      Parameters:
      entity - a managed persistent instance
      lockMode - the lock level
    • find

      @Incubating public <T> io.smallrye.mutiny.Uni<T> find(Class<T> entityClass, Identifier<T> naturalId)
      Description copied from interface: Mutiny.Session
      Asynchronously return the persistent instance of the given entity class with the given natural identifier, or null if there is no such persistent instance.
      Specified by:
      find in interface Mutiny.Session
      Parameters:
      entityClass - The entity type
      naturalId - the natural identifier
      Returns:
      a persistent instance or null via a Uni
    • withTransaction

      public <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
      Description copied from interface: Mutiny.Session
      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 Mutiny.Transaction.markForRollback() is called.

      The resulting Mutiny.Transaction object may also be obtained via Mutiny.Session.currentTransaction().

    • 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 Mutiny.Session
      Parameters:
      work - a function which accepts Mutiny.Transaction and returns the result of the work as a Uni.
      See Also:
    • createNativeQuery

      public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given SQL query string, using the given ResultSetMapping to interpret the result set.
      Specified by:
      createNativeQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The SQL query
      resultSetMapping - the result set mapping
      Returns:
      The Mutiny.Query instance for manipulation and execution
      See Also:
    • createEntityGraph

      public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(Class<T> rootType, String graphName)
      Description copied from interface: Mutiny.QueryProducer
      Create a new mutable copy of a named EntityGraph
      Specified by:
      createEntityGraph in interface Mutiny.QueryProducer
    • currentTransaction

      public Mutiny.Transaction currentTransaction()
      Description copied from interface: Mutiny.Session
      Obtain the transaction currently associated with this session, if any.
      Specified by:
      currentTransaction in interface Mutiny.Session
      Returns:
      the Mutiny.Transaction, or null if no transaction was started using Mutiny.Session.withTransaction(Function).
      See Also:
    • detach

      public Mutiny.Session detach(Object entity)
      Description copied from interface: Mutiny.Session
      Remove this instance from the session cache. Changes to the instance will not be synchronized with the database.

      This operation cascades to associated instances if the association is mapped with CascadeType.DETACH.

      Specified by:
      detach in interface Mutiny.Session
      Parameters:
      entity - The entity to evict
      See Also:
      • EntityManager.detach(Object)
    • setCacheStoreMode

      public Mutiny.Session setCacheStoreMode(jakarta.persistence.CacheStoreMode cacheStoreMode)
      Description copied from interface: Mutiny.Session
      Set the CacheStoreMode for this session.
      Specified by:
      setCacheStoreMode in interface Mutiny.Session
      Parameters:
      cacheStoreMode - The new cache store mode.
    • getFlushMode

      public FlushMode getFlushMode()
      Description copied from interface: Mutiny.Session
      Get the current flush mode for this session.
      Specified by:
      getFlushMode in interface Mutiny.Session
      Returns:
      the flush mode
    • getLockMode

      public LockMode getLockMode(Object entity)
      Description copied from interface: Mutiny.Session
      Determine the current lock mode of the given entity.
      Specified by:
      getLockMode in interface Mutiny.Session
    • createNamedQuery

      public <R> Mutiny.Query<R> createNamedQuery(String queryName)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.Query for the named query.
      Specified by:
      createNamedQuery in interface Mutiny.QueryProducer
      Parameters:
      queryName - The name of the query
      Returns:
      The Mutiny.Query instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String)
    • getCriteriaBuilder

      public jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
      Description copied from interface: Mutiny.QueryProducer
      Convenience method to obtain the CriteriaBuilder.
      Specified by:
      getCriteriaBuilder in interface Mutiny.QueryProducer
    • getFactory

      public Mutiny.SessionFactory getFactory()
      Description copied from interface: Mutiny.Session
      The Mutiny.SessionFactory which created this session.
      Specified by:
      getFactory in interface Mutiny.Session
    • createNativeQuery

      public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, Class<R> resultType)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given SQL query string, using the given resultType to interpret the results.
      • If the given result type is Object, or a built-in type such as String or Integer, the result set must have a single column, which will be returned as a scalar.
      • If the given result type is Object[], then the result set must have multiple columns, which will be returned in arrays.
      • Otherwise, the given result type must be an entity class, in which case the result set column aliases must map to the fields of the entity, and the query will return instances of the entity.
      Specified by:
      createNativeQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The SQL query
      resultType - the Java type returned in each row of query results
      Returns:
      The Mutiny.SelectionQuery instance for manipulation and execution
      See Also:
      • EntityManager.createNativeQuery(String, Class)
    • setSubselectFetchingEnabled

      public Mutiny.Session setSubselectFetchingEnabled(boolean enabled)
      Description copied from interface: Mutiny.Session
      Enable or disable subselect fetching in this session. Override the default controlled by the configuration property hibernate.use_subselect_fetch.
      Specified by:
      setSubselectFetchingEnabled in interface Mutiny.Session
      Parameters:
      enabled - true to enable subselect fetching
    • setFlushMode

      public Mutiny.Session setFlushMode(FlushMode flushMode)
      Description copied from interface: Mutiny.Session
      Set the flush mode for this session.

      The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.

      For a logically "read only" session, it is reasonable to set the session's flush mode to FlushMode.MANUAL at the start of the session (in order to achieve some extra performance).

      Specified by:
      setFlushMode in interface Mutiny.Session
      Parameters:
      flushMode - the new flush mode
    • remove

      public io.smallrye.mutiny.Uni<Void> remove(Object entity)
      Description copied from interface: Mutiny.Session
      Asynchronously remove a persistent instance from the datastore. The argument may be an instance associated with the receiving session or a transient instance with an identifier associated with existing persistent state.

      This operation cascades to associated instances if the association is mapped with CascadeType.REMOVE.

       session.delete(book).thenAccept(v -> session.flush());
       
      Specified by:
      remove in interface Mutiny.Session
      Parameters:
      entity - the managed persistent instance to be removed
      See Also:
      • EntityManager.remove(Object)
    • setCacheMode

      public Mutiny.Session setCacheMode(CacheMode cacheMode)
      Description copied from interface: Mutiny.Session
      Set the cache mode for this session.

      The cache mode determines the manner in which this session interacts with the second level cache.

      Specified by:
      setCacheMode in interface Mutiny.Session
      Parameters:
      cacheMode - The new cache mode.
    • enableFilter

      public Filter enableFilter(String filterName)
      Description copied from interface: Mutiny.Session
      Enable the named filter for this session.
      Specified by:
      enableFilter in interface Mutiny.Session
      Parameters:
      filterName - The name of the filter to be enabled.
      Returns:
      The Filter instance representing the enabled filter.
    • createMutationQuery

      public Mutiny.MutationQuery createMutationQuery(JpaCriteriaInsert<?> insert)
      Description copied from interface: Mutiny.QueryProducer
      Create a Mutiny.MutationQuery from the given insert select criteria tree
      Specified by:
      createMutationQuery in interface Mutiny.QueryProducer
      Parameters:
      insert - the insert select criteria query
      Returns:
      The Mutiny.MutationQuery instance for manipulation and execution
      See Also:
    • createNativeQuery

      public <R> Mutiny.Query<R> createNativeQuery(String queryString, AffectedEntities affectedEntities)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.Query for the given SQL query string, or SQL update, insert, or delete statement. In the case of an update, insert, or delete, the returned Mutiny.Query must be executed using Mutiny.MutationQuery.executeUpdate() which returns an affected row count. In the case of a query:
      • If the result set has a single column, the results will be returned as scalars.
      • Otherwise, if the result set has multiple columns, the results will be returned as elements of arrays of type Object[].

      Any affected entities are synchronized with the database before execution of the statement.

      Specified by:
      createNativeQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The SQL select, update, insert, or delete statement
      affectedEntities - The entities which are affected by the statement
    • setReadOnly

      public Mutiny.Session setReadOnly(Object entityOrProxy, boolean readOnly)
      Description copied from interface: Mutiny.Session
      Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. In read-only mode, no snapshot is maintained, the instance is never dirty checked, and changes are not persisted.
      Specified by:
      setReadOnly in interface Mutiny.Session
      See Also:
    • createEntityGraph

      public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(Class<T> rootType)
      Description copied from interface: Mutiny.QueryProducer
      Create a new mutable EntityGraph
      Specified by:
      createEntityGraph in interface Mutiny.QueryProducer
    • refreshAll

      public io.smallrye.mutiny.Uni<Void> refreshAll(Object... entities)
      Description copied from interface: Mutiny.Session
      Refresh multiple entity instances at once.
      Specified by:
      refreshAll in interface Mutiny.Session
      See Also:
    • createMutationQuery

      public Mutiny.MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaDelete<?> deleteQuery)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.MutationQuery for the given delete tree.
      Specified by:
      createMutationQuery in interface Mutiny.QueryProducer
      Parameters:
      deleteQuery - the delete criteria query
      Returns:
      The Mutiny.MutationQuery instance for manipulation and execution
      See Also:
    • getBatchSize

      public Integer getBatchSize()
      Description copied from interface: Mutiny.Session
      The session-level batch size, or null if it has not been overridden.
      Specified by:
      getBatchSize in interface Mutiny.Session
    • refresh

      public io.smallrye.mutiny.Uni<Void> refresh(Object entity, LockMode lockMode)
      Description copied from interface: Mutiny.Session
      Re-read the state of the given instance from the underlying database, requesting the given LockMode.
      Specified by:
      refresh in interface Mutiny.Session
      Parameters:
      entity - a managed persistent entity instance
      lockMode - the requested lock mode
      See Also:
    • getReference

      public <T> T getReference(Class<T> entityClass, Object id)
      Description copied from interface: Mutiny.Session
      Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists. This method never results in access to the underlying data store, and thus might return a proxied instance that must be initialized explicitly using Mutiny.Session.fetch(Object).

      You should not use this method to determine if an instance exists (use Mutiny.Session.find(java.lang.Class<T>, java.lang.Object) instead). Use this only to retrieve an instance which you safely assume exists, where non-existence would be an actual error.

      Specified by:
      getReference in interface Mutiny.Session
      Parameters:
      entityClass - a persistent class
      id - a valid identifier of an existing persistent instance of the class
      Returns:
      the persistent instance or proxy
      See Also:
      • EntityManager.getReference(Class, Object)
    • getReference

      public <T> T getReference(T entity)
      Description copied from interface: Mutiny.Session
      Return the persistent instance with the same identity as the given instance, which might be detached, assuming that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that must be initialized explicitly using Mutiny.Session.fetch(Object).
      Specified by:
      getReference in interface Mutiny.Session
      Parameters:
      entity - a detached persistent instance
      Returns:
      the persistent instance or proxy
    • setBatchSize

      public Mutiny.Session setBatchSize(Integer batchSize)
      Description copied from interface: Mutiny.Session
      Set the session-level batch size, overriding the batch size set by the configuration property hibernate.jdbc.batch_size.
      Specified by:
      setBatchSize in interface Mutiny.Session
    • refresh

      public io.smallrye.mutiny.Uni<Void> refresh(Object entity)
      Description copied from interface: Mutiny.Session
      Re-read the state of the given instance from the underlying database. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances, for example:
      • where a database trigger alters the object state after insert or update, or
      • after executing direct native SQL in the same session.
      Specified by:
      refresh in interface Mutiny.Session
      Parameters:
      entity - a managed persistent instance
      See Also:
      • EntityManager.refresh(Object)
    • getCacheMode

      public CacheMode getCacheMode()
      Description copied from interface: Mutiny.Session
      Get the current cache mode.
      Specified by:
      getCacheMode in interface Mutiny.Session
      Returns:
      The current cache mode.
    • mergeAll

      public io.smallrye.mutiny.Uni<Void> mergeAll(Object... entities)
      Description copied from interface: Mutiny.Session
      Merge multiple entity instances at once.
      Specified by:
      mergeAll in interface Mutiny.Session
      See Also:
    • persist

      public io.smallrye.mutiny.Uni<Void> persist(Object object)
      Description copied from interface: Mutiny.Session
      Asynchronously persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the entity has assigned identifiers.)

      This operation cascades to associated instances if the association is mapped with CascadeType.PERSIST.

       session.persist(newBook).map(v -> session.flush());
       
      Specified by:
      persist in interface Mutiny.Session
      Parameters:
      object - a transient instance of a persistent class
      See Also:
      • EntityManager.persist(Object)
    • contains

      public boolean contains(Object entity)
      Description copied from interface: Mutiny.Session
      Determine if the given instance belongs to this persistence context.
      Specified by:
      contains in interface Mutiny.Session
    • createMutationQuery

      public Mutiny.MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate<?> updateQuery)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.MutationQuery for the given update tree.
      Specified by:
      createMutationQuery in interface Mutiny.QueryProducer
      Parameters:
      updateQuery - the update criteria query
      Returns:
      The Mutiny.MutationQuery instance for manipulation and execution
      See Also:
    • getFetchBatchSize

      public int getFetchBatchSize()
      Description copied from interface: Mutiny.Session
      Get the maximum batch size for batch fetching associations by id in this session.
      Specified by:
      getFetchBatchSize in interface Mutiny.Session
    • setDefaultReadOnly

      public Mutiny.Session setDefaultReadOnly(boolean readOnly)
      Description copied from interface: Mutiny.Session
      Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.

      Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted.

      Specified by:
      setDefaultReadOnly in interface Mutiny.Session
      See Also:
    • clear

      public Mutiny.Session clear()
      Description copied from interface: Mutiny.Session
      Completely clear the session. Detach all persistent instances and cancel all pending insertions, updates and deletions.
      Specified by:
      clear in interface Mutiny.Session
      See Also:
      • EntityManager.clear()
    • fetch

      public <E, T> io.smallrye.mutiny.Uni<T> fetch(E entity, jakarta.persistence.metamodel.Attribute<E,T> field)
      Description copied from interface: Mutiny.Session
      Fetch a lazy property of the given entity, identified by a JPA attribute metamodel. Note that this feature is only supported in conjunction with the Hibernate bytecode enhancer.
       session.fetch(book, Book_.isbn).thenAccept(isbn -> print(isbn))
       
      Specified by:
      fetch in interface Mutiny.Session
    • createQuery

      public <R> Mutiny.SelectionQuery<R> createQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.SelectionQuery for the given criteria query.
      Specified by:
      createQuery in interface Mutiny.QueryProducer
      Parameters:
      criteriaQuery - The CriteriaQuery
      Returns:
      The Mutiny.SelectionQuery instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String)
    • setCacheRetrieveMode

      public Mutiny.Session setCacheRetrieveMode(jakarta.persistence.CacheRetrieveMode cacheRetrieveMode)
      Description copied from interface: Mutiny.Session
      Set the CacheRetrieveMode for this session.
      Specified by:
      setCacheRetrieveMode in interface Mutiny.Session
      Parameters:
      cacheRetrieveMode - The new cache retrieve mode.
    • removeAll

      public io.smallrye.mutiny.Uni<Void> removeAll(Object... entities)
      Description copied from interface: Mutiny.Session
      Remove multiple entity instances at once.
      Specified by:
      removeAll in interface Mutiny.Session
      See Also:
    • getEnabledFilter

      public Filter getEnabledFilter(String filterName)
      Description copied from interface: Mutiny.Session
      Retrieve a currently enabled filter by name.
      Specified by:
      getEnabledFilter in interface Mutiny.Session
      Parameters:
      filterName - The name of the filter to be retrieved.
      Returns:
      The Filter instance representing the enabled filter.
    • disableFilter

      public void disableFilter(String filterName)
      Description copied from interface: Mutiny.Session
      Disable the named filter for this session.
      Specified by:
      disableFilter in interface Mutiny.Session
      Parameters:
      filterName - The name of the filter to be disabled.
    • createQuery

      public <R> Mutiny.MutationQuery createQuery(jakarta.persistence.criteria.CriteriaDelete<R> criteriaDelete)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.MutationQuery for the given criteria delete.
      Specified by:
      createQuery in interface Mutiny.QueryProducer
      Parameters:
      criteriaDelete - The CriteriaDelete
      Returns:
      The Mutiny.MutationQuery instance for manipulation and execution
    • enableFetchProfile

      public Mutiny.Session enableFetchProfile(String name)
      Description copied from interface: Mutiny.Session
      Enable a particular fetch profile on this session, or do nothing if requested fetch profile is already enabled.
      Specified by:
      enableFetchProfile in interface Mutiny.Session
      Parameters:
      name - The name of the fetch profile to be enabled.
      See Also:
    • getResultSetMapping

      public <T> ResultSetMapping<T> getResultSetMapping(Class<T> resultType, String mappingName)
      Description copied from interface: Mutiny.QueryProducer
      Obtain a native SQL result set mapping defined via the annotation SqlResultSetMapping.
      Specified by:
      getResultSetMapping in interface Mutiny.QueryProducer
    • flush

      public io.smallrye.mutiny.Uni<Void> flush()
      Description copied from interface: Mutiny.Session
      Force this session to flush asynchronously. Must be called at the end of a unit of work, before committing the transaction and closing the session. Flushing is the process of synchronizing the underlying persistent store with state held in memory.
       session.flush().thenAccept(v -> print("done saving changes"));
       
      Specified by:
      flush in interface Mutiny.Session
      See Also:
      • EntityManager.flush()
    • persist

      public io.smallrye.mutiny.Uni<Void> persist(String entityName, Object object)
      Description copied from interface: Mutiny.Session
      Make a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped with CascadeType.PERSIST.

      For entities with a generated id, persist() ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.

      Specified by:
      persist in interface Mutiny.Session
      Parameters:
      entityName - the entity name
      object - a transient instance to be made persistent
      See Also:
    • createNativeQuery

      public <R> Mutiny.Query<R> createNativeQuery(String queryString)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.Query for the given SQL query string, or SQL update, insert, or delete statement. In the case of an update, insert, or delete, the returned Mutiny.Query must be executed using Mutiny.MutationQuery.executeUpdate() which returns an affected row count. In the case of a query:
      • If the result set has a single column, the results will be returned as scalars.
      • Otherwise, if the result set has multiple columns, the results will be returned as elements of arrays of type Object[].
      Specified by:
      createNativeQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The SQL select, update, insert, or delete statement
    • isFetchProfileEnabled

      public boolean isFetchProfileEnabled(String name)
      Description copied from interface: Mutiny.Session
      Determine if the fetch profile with the given name is enabled for this session.
      Specified by:
      isFetchProfileEnabled in interface Mutiny.Session
      Parameters:
      name - The name of the profile to be checked.
      Returns:
      True if fetch profile is enabled; false if not.
      See Also:
    • merge

      public <T> io.smallrye.mutiny.Uni<T> merge(T entity)
      Description copied from interface: Mutiny.Session
      Copy the state of the given object onto the persistent instance with the same identifier. If there is no such persistent instance currently associated with the session, it will be loaded. Return the persistent instance. Or, if the given instance is transient, save a copy of it and return the copy as a newly persistent instance. The given instance does not become associated with the session.

      This operation cascades to associated instances if the association is mapped with CascadeType.MERGE.

      Specified by:
      merge in interface Mutiny.Session
      Parameters:
      entity - a detached instance with state to be copied
      Returns:
      an updated persistent instance
      See Also:
      • EntityManager.merge(Object)
    • isSubselectFetchingEnabled

      public boolean isSubselectFetchingEnabled()
      Description copied from interface: Mutiny.Session
      Determine if subselect fetching is enabled in this session.
      Specified by:
      isSubselectFetchingEnabled in interface Mutiny.Session
      Returns:
      true if subselect fetching is enabled
    • createQuery

      public <R> Mutiny.MutationQuery createQuery(jakarta.persistence.criteria.CriteriaUpdate<R> criteriaUpdate)
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.MutationQuery for the given criteria update.
      Specified by:
      createQuery in interface Mutiny.QueryProducer
      Parameters:
      criteriaUpdate - The CriteriaUpdate
      Returns:
      The Mutiny.MutationQuery instance for manipulation and execution
    • setFetchBatchSize

      public Mutiny.Session setFetchBatchSize(int batchSize)
      Description copied from interface: Mutiny.Session
      Set the maximum batch size for batch fetching associations by id in this session. Override the default controlled by the configuration property hibernate.default_batch_fetch_size.

      • If batchSize>1, then batch fetching is enabled.
      • If batchSize<0, the batch size is inherited from the factory-level setting.
      • Otherwise, batch fetching is disabled.
      Specified by:
      setFetchBatchSize in interface Mutiny.Session
      Parameters:
      batchSize - the maximum batch size for batch fetching
    • fetch

      public <T> io.smallrye.mutiny.Uni<T> fetch(T association)
      Description copied from interface: Mutiny.Session
      Asynchronously fetch an association configured for lazy loading.

       session.fetch(author.getBook()).thenAccept(book -> print(book.getTitle()));
       

      This operation may be even be used to initialize a reference returned by Mutiny.Session.getReference(Class, Object).

       session.fetch(session.getReference(Author.class, authorId))
       

      Specified by:
      fetch in interface Mutiny.Session
      Parameters:
      association - a lazy-loaded association, or a proxy
      Returns:
      the fetched association, via a Uni
      See Also:
    • persistAll

      public io.smallrye.mutiny.Uni<Void> persistAll(Object... entities)
      Description copied from interface: Mutiny.Session
      Persist multiple transient entity instances at once.
      Specified by:
      persistAll in interface Mutiny.Session
      See Also:
    • createQuery

      @Deprecated public <R> Mutiny.Query<R> createQuery(String queryString)
      Deprecated.
      Description copied from interface: Mutiny.QueryProducer
      Create an instance of Mutiny.Query for the given HQL/JPQL query string or HQL/JPQL update or delete statement. In the case of an update or delete, the returned Mutiny.Query must be executed using Mutiny.MutationQuery.executeUpdate() which returns an affected row count.
      Specified by:
      createQuery in interface Mutiny.QueryProducer
      Parameters:
      queryString - The HQL/JPQL query, update or delete statement
      Returns:
      The Mutiny.Query instance for manipulation and execution
      See Also:
      • EntityManager.createQuery(String)
    • setFlushMode

      public Mutiny.Session setFlushMode(jakarta.persistence.FlushModeType flushModeType)
      Description copied from interface: Mutiny.Session
      Set the flush mode for this session.

      The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.

      Specified by:
      setFlushMode in interface Mutiny.Session
      Parameters:
      flushModeType - the new flush mode
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Mutiny.Session
      Returns:
      false if Mutiny.Closeable.close() has been called