Class MutinySessionDelegator
- All Implemented Interfaces:
Mutiny.Closeable,Mutiny.QueryProducer,Mutiny.Session
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclear()Completely clear the session.io.smallrye.mutiny.Uni<Void>close()booleanDetermine if the given instance belongs to this persistence context.<T> jakarta.persistence.EntityGraph<T>createEntityGraph(Class<T> rootType) Create a new mutableEntityGraph<T> jakarta.persistence.EntityGraph<T>createEntityGraph(Class<T> rootType, String graphName) Create a new mutable copy of a namedEntityGraphcreateMutationQuery(jakarta.persistence.criteria.CriteriaDelete<?> deleteQuery) Create an instance ofMutiny.MutationQueryfor the given delete tree.createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate<?> updateQuery) Create an instance ofMutiny.MutationQueryfor the given update tree.createMutationQuery(String queryString) Create an instance ofMutiny.MutationQueryfor the given HQL/JPQL update or delete statement.createMutationQuery(JpaCriteriaInsert<?> insert) Create aMutiny.MutationQueryfrom the given insert select criteria tree<R> Mutiny.Query<R>createNamedQuery(String queryName) Create an instance ofMutiny.Queryfor the named query.<R> Mutiny.SelectionQuery<R>createNamedQuery(String queryName, Class<R> resultType) Create an instance ofMutiny.SelectionQueryfor the named query.<R> Mutiny.Query<R>createNativeQuery(String queryString) Create an instance ofMutiny.Queryfor the given SQL query string, or SQL update, insert, or delete statement.<R> Mutiny.SelectionQuery<R>createNativeQuery(String queryString, Class<R> resultType) Create an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenresultTypeto interpret the results.<R> Mutiny.SelectionQuery<R>createNativeQuery(String queryString, Class<R> resultType, AffectedEntities affectedEntities) Create an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenresultTypeto interpret the results.<R> Mutiny.Query<R>createNativeQuery(String queryString, AffectedEntities affectedEntities) Create an instance ofMutiny.Queryfor the given SQL query string, or SQL update, insert, or delete statement.<R> Mutiny.SelectionQuery<R>createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping) Create an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenResultSetMappingto interpret the result set.<R> Mutiny.SelectionQuery<R>createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping, AffectedEntities affectedEntities) Create an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenResultSetMappingto interpret the result set.createQuery(jakarta.persistence.criteria.CriteriaDelete<R> criteriaDelete) Create an instance ofMutiny.MutationQueryfor the given criteria delete.<R> Mutiny.SelectionQuery<R>createQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery) Create an instance ofMutiny.SelectionQueryfor the given criteria query.createQuery(jakarta.persistence.criteria.CriteriaUpdate<R> criteriaUpdate) Create an instance ofMutiny.MutationQueryfor the given criteria update.<R> Mutiny.Query<R>createQuery(jakarta.persistence.TypedQueryReference<R> typedQueryReference) Create a typedQueryinstance for the given typed query reference.<R> Mutiny.Query<R>createQuery(String queryString) Deprecated.<R> Mutiny.SelectionQuery<R>createQuery(String queryString, Class<R> resultType) Create an instance ofMutiny.SelectionQueryfor the given HQL/JPQL query string and query result type.<R> Mutiny.SelectionQuery<R>createSelectionQuery(String queryString, Class<R> resultType) Create an instance ofMutiny.SelectionQueryfor the given HQL/JPQL query string.Obtain the transaction currently associated with this session, if any.abstract Mutiny.Sessiondelegate()Remove this instance from the session cache.disableFetchProfile(String name) Disable a particular fetch profile on this session, or do nothing if the requested fetch profile is not enabled.voiddisableFilter(String filterName) Disable the named filter for this session.enableFetchProfile(String name) Enable a particular fetch profile on this session, or do nothing if requested fetch profile is already enabled.enableFilter(String filterName) Enable the named filter for this session.<E,T> io.smallrye.mutiny.Uni<T> fetch(E entity, jakarta.persistence.metamodel.Attribute<E, T> field) Fetch a lazy property of the given entity, identified by a JPAattribute metamodel.<T> io.smallrye.mutiny.Uni<T>fetch(T association) Asynchronously fetch an association configured for lazy loading.<T> io.smallrye.mutiny.Uni<T>Asynchronously return the persistent instance with the given identifier of an entity class, using the givenEntityGraphas a fetch plan.<T> io.smallrye.mutiny.Uni<T>Asynchronously return the persistent instance of the given entity class with the given identifier, ornullif there is no such persistent instance.<T> io.smallrye.mutiny.Uni<List<T>>Asynchronously return the persistent instances of the given entity class with the given identifiers, or null if there is no such persistent instance.<T> io.smallrye.mutiny.Uni<T>Asynchronously return the persistent instance of the given entity class with the given identifier, requesting the givenLockModeType.<T> io.smallrye.mutiny.Uni<T>Asynchronously return the persistent instance of the given entity class with the given identifier, requesting the givenLockMode.<T> io.smallrye.mutiny.Uni<T>find(Class<T> entityClass, Identifier<T> naturalId) Asynchronously return the persistent instance of the given entity class with the given natural identifier, or null if there is no such persistent instance.io.smallrye.mutiny.Uni<Void>flush()Force this session to flush asynchronously.The session-level batch size, ornullif it has not been overridden.Get the current cache mode.jakarta.persistence.criteria.CriteriaBuilderConvenience method to obtain theCriteriaBuilder.getEnabledFilter(String filterName) Retrieve a currently enabled filter by name.<T> jakarta.persistence.EntityGraph<T>getEntityGraph(Class<T> rootType, String graphName) Obtain a namedEntityGraphTheMutiny.SessionFactorywhich created this session.intGet the maximum batch size for batch fetching associations by id in this session.Get the current flush mode for this session.getLockMode(Object entity) Determine the current lock mode of the given entity.<T> TgetReference(Class<T> entityClass, Object id) Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.<T> TgetReference(T entity) 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.<T> ResultSetMapping<T>getResultSetMapping(Class<T> resultType, String mappingName) Obtain a native SQL result set mapping defined via the annotationSqlResultSetMapping.booleanbooleanisFetchProfileEnabled(String name) Determine if the fetch profile with the given name is enabled for this session.booleanisOpen()booleanisReadOnly(Object entityOrProxy) Is the specified entity or proxy read-only?booleanDetermine if subselect fetching is enabled in this session.io.smallrye.mutiny.Uni<Void>Obtain the specified lock level upon the given object.io.smallrye.mutiny.Uni<Void>Obtain the specified lock level upon the given object.<T> io.smallrye.mutiny.Uni<T>merge(T entity) Copy the state of the given object onto the persistent instance with the same identifier.io.smallrye.mutiny.Uni<Void>Merge multiple entity instances at once.io.smallrye.mutiny.Uni<Void>Asynchronously persist the given transient instance, first assigning a generated identifier.io.smallrye.mutiny.Uni<Void>Make a transient instance persistent and mark it for later insertion in the database.io.smallrye.mutiny.Uni<Void>persistAll(Object... entities) Persist multiple transient entity instances at once.io.smallrye.mutiny.Uni<Void>Re-read the state of the given instance from the underlying database.io.smallrye.mutiny.Uni<Void>Re-read the state of the given instance from the underlying database, requesting the givenLockModeType.io.smallrye.mutiny.Uni<Void>Re-read the state of the given instance from the underlying database, requesting the givenLockMode.io.smallrye.mutiny.Uni<Void>refreshAll(Object... entities) Refresh multiple entity instances at once.io.smallrye.mutiny.Uni<Void>Asynchronously remove a persistent instance from the datastore.io.smallrye.mutiny.Uni<Void>Remove multiple entity instances at once.setBatchSize(Integer batchSize) Set the session-level batch size, overriding the batch size set by the configuration propertyhibernate.jdbc.batch_size.setCacheMode(CacheMode cacheMode) Set thecache modefor this session.setCacheRetrieveMode(jakarta.persistence.CacheRetrieveMode cacheRetrieveMode) Set theCacheRetrieveModefor this session.setCacheStoreMode(jakarta.persistence.CacheStoreMode cacheStoreMode) Set theCacheStoreModefor this session.setDefaultReadOnly(boolean readOnly) Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.setFetchBatchSize(int batchSize) Set the maximum batch size for batch fetching associations by id in this session.setFlushMode(jakarta.persistence.FlushModeType flushModeType) Set theflush modefor this session.setFlushMode(FlushMode flushMode) Set theflush modefor this session.setReadOnly(Object entityOrProxy, boolean readOnly) Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.setSubselectFetchingEnabled(boolean enabled) Enable or disable subselect fetching in this session.<T> io.smallrye.mutiny.Uni<T>unproxy(T association) Asynchronously fetch an association that's configured for lazy loading, and unwrap the underlying entity implementation from any proxy.<T> io.smallrye.mutiny.Uni<T>withTransaction(Function<Mutiny.Transaction, io.smallrye.mutiny.Uni<T>> work) Performs the given work within the scope of a database transaction, automatically flushing the session.
-
Constructor Details
-
MutinySessionDelegator
public MutinySessionDelegator()
-
-
Method Details
-
delegate
-
find
Description copied from interface:Mutiny.SessionAsynchronously return the persistent instance of the given entity class with the given identifier, ornullif 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:
findin interfaceMutiny.Session- Parameters:
entityClass- The entity typeid- 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.SessionAsynchronously return the persistent instance of the given entity class with the given identifier, requesting the givenLockModeType.- Specified by:
findin interfaceMutiny.Session- Parameters:
entityClass- The entity typeid- an identifierlockModeType- the requestedLockModeType- Returns:
- a persistent instance or null via a
Uni - See Also:
-
find
Description copied from interface:Mutiny.SessionAsynchronously return the persistent instance of the given entity class with the given identifier, requesting the givenLockMode.- Specified by:
findin interfaceMutiny.Session- Parameters:
entityClass- The entity typeid- an identifierlockMode- the requestedLockMode- 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.SessionAsynchronously return the persistent instance with the given identifier of an entity class, using the givenEntityGraphas a fetch plan.- Specified by:
findin interfaceMutiny.Session- Parameters:
entityGraph- anEntityGraphspecifying the entity and associations to be fetchedid- an identifier- See Also:
-
find
Description copied from interface:Mutiny.SessionAsynchronously return the persistent instances of the given entity class with the given identifiers, or null if there is no such persistent instance.- Specified by:
findin interfaceMutiny.Session- Parameters:
entityClass- The entity typeids- the identifiers- Returns:
- a list of persistent instances and nulls via a
Uni - See Also:
-
createNamedQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the named query.- Specified by:
createNamedQueryin interfaceMutiny.QueryProducer- Parameters:
queryName- The name of the queryresultType- the Java type returned in each row of query results- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
-
EntityManager.createQuery(String, Class)
-
createQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given HQL/JPQL query string and query result type.- Specified by:
createQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The HQL/JPQL queryresultType- the Java type returned in each row of query results- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
-
EntityManager.createQuery(String, Class)
-
isReadOnly
Description copied from interface:Mutiny.SessionIs the specified entity or proxy read-only?- Specified by:
isReadOnlyin interfaceMutiny.Session- See Also:
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, Class<R> resultType, AffectedEntities affectedEntities) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenresultTypeto interpret the results.- If the given result type is
Object, or a built-in type such asStringorInteger, 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 entitiesare synchronized with the database before execution of the query.- Specified by:
createNativeQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The SQL queryresultType- the Java type returned in each row of query resultsaffectedEntities- The entities which are affected by the query- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
-
EntityManager.createNativeQuery(String, Class)
- If the given result type is
-
isDefaultReadOnly
public boolean isDefaultReadOnly()- Specified by:
isDefaultReadOnlyin interfaceMutiny.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.SessionAsynchronously 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:
unproxyin interfaceMutiny.Session- Parameters:
association- a lazy-loaded association- Returns:
- the fetched association, via a
Uni - See Also:
-
createMutationQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.MutationQueryfor the given HQL/JPQL update or delete statement.- Specified by:
createMutationQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The HQL/JPQL query, update or delete statement- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution - See Also:
-
EntityManager.createQuery(String)
-
close
- Specified by:
closein interfaceMutiny.Closeable
-
disableFetchProfile
Description copied from interface:Mutiny.SessionDisable a particular fetch profile on this session, or do nothing if the requested fetch profile is not enabled.- Specified by:
disableFetchProfilein interfaceMutiny.Session- Parameters:
name- The name of the fetch profile to be disabled.- See Also:
-
getEntityGraph
Description copied from interface:Mutiny.QueryProducerObtain a namedEntityGraph- Specified by:
getEntityGraphin interfaceMutiny.QueryProducer
-
createSelectionQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given HQL/JPQL query string.- Specified by:
createSelectionQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The HQL/JPQL query- Returns:
- The
Mutiny.SelectionQueryinstance 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.SessionRe-read the state of the given instance from the underlying database, requesting the givenLockModeType.- Specified by:
refreshin interfaceMutiny.Session- Parameters:
entity- a managed persistent entity instancelockModeType- 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.SessionObtain 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:
lockin interfaceMutiny.Session- Parameters:
entity- a managed persistent instancelockModeType- the lock level
- perform a version check with
-
createQuery
public <R> Mutiny.Query<R> createQuery(jakarta.persistence.TypedQueryReference<R> typedQueryReference) Description copied from interface:Mutiny.QueryProducerCreate a typedQueryinstance for the given typed query reference.- Specified by:
createQueryin interfaceMutiny.QueryProducer- Parameters:
typedQueryReference- the type query reference- Returns:
- The
Queryinstance for execution - See Also:
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping, AffectedEntities affectedEntities) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenResultSetMappingto interpret the result set.Any
affected entitiesare synchronized with the database before execution of the query.- Specified by:
createNativeQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The SQL queryresultSetMapping- the result set mappingaffectedEntities- The entities which are affected by the query- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
-
Mutiny.QueryProducer.getResultSetMapping(Class, String)EntityManager.createNativeQuery(String, String)
-
lock
Description copied from interface:Mutiny.SessionObtain the specified lock level upon the given object. For example, this operation may be used to:- perform a version check with
LockMode.PESSIMISTIC_READ, - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_WRITE, - force a version increment with
LockMode.PESSIMISTIC_FORCE_INCREMENT, - schedule a version check just before the end of the transaction with
LockMode.OPTIMISTIC, or - schedule a version increment just before the end of the transaction
with
LockMode.OPTIMISTIC_FORCE_INCREMENT.
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK.- Specified by:
lockin interfaceMutiny.Session- Parameters:
entity- a managed persistent instancelockMode- the lock level
- perform a version check with
-
find
@Incubating public <T> io.smallrye.mutiny.Uni<T> find(Class<T> entityClass, Identifier<T> naturalId) Description copied from interface:Mutiny.SessionAsynchronously 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:
findin interfaceMutiny.Session- Parameters:
entityClass- The entity typenaturalId- 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.SessionPerforms 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 ifMutiny.Transaction.markForRollback()is called.The resulting
Mutiny.Transactionobject may also be obtained viaMutiny.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:
withTransactionin interfaceMutiny.Session- Parameters:
work- a function which acceptsMutiny.Transactionand returns the result of the work as aUni.- See Also:
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenResultSetMappingto interpret the result set.- Specified by:
createNativeQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The SQL queryresultSetMapping- the result set mapping- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
-
Mutiny.QueryProducer.getResultSetMapping(Class, String)EntityManager.createNativeQuery(String, String)
-
createEntityGraph
public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(Class<T> rootType, String graphName) Description copied from interface:Mutiny.QueryProducerCreate a new mutable copy of a namedEntityGraph- Specified by:
createEntityGraphin interfaceMutiny.QueryProducer
-
currentTransaction
Description copied from interface:Mutiny.SessionObtain the transaction currently associated with this session, if any.- Specified by:
currentTransactionin interfaceMutiny.Session- Returns:
- the
Mutiny.Transaction, or null if no transaction was started usingMutiny.Session.withTransaction(Function). - See Also:
-
detach
Description copied from interface:Mutiny.SessionRemove 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:
detachin interfaceMutiny.Session- Parameters:
entity- The entity to evict- See Also:
-
EntityManager.detach(Object)
-
setCacheStoreMode
Description copied from interface:Mutiny.SessionSet theCacheStoreModefor this session.- Specified by:
setCacheStoreModein interfaceMutiny.Session- Parameters:
cacheStoreMode- The new cache store mode.
-
getFlushMode
Description copied from interface:Mutiny.SessionGet the current flush mode for this session.- Specified by:
getFlushModein interfaceMutiny.Session- Returns:
- the flush mode
-
getLockMode
Description copied from interface:Mutiny.SessionDetermine the current lock mode of the given entity.- Specified by:
getLockModein interfaceMutiny.Session
-
createNamedQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.Queryfor the named query.- Specified by:
createNamedQueryin interfaceMutiny.QueryProducer- Parameters:
queryName- The name of the query- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
-
EntityManager.createQuery(String)
-
getCriteriaBuilder
public jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()Description copied from interface:Mutiny.QueryProducerConvenience method to obtain theCriteriaBuilder.- Specified by:
getCriteriaBuilderin interfaceMutiny.QueryProducer
-
getFactory
Description copied from interface:Mutiny.SessionTheMutiny.SessionFactorywhich created this session.- Specified by:
getFactoryin interfaceMutiny.Session
-
createNativeQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenresultTypeto interpret the results.- If the given result type is
Object, or a built-in type such asStringorInteger, 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:
createNativeQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The SQL queryresultType- the Java type returned in each row of query results- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
-
EntityManager.createNativeQuery(String, Class)
- If the given result type is
-
setSubselectFetchingEnabled
Description copied from interface:Mutiny.SessionEnable or disable subselect fetching in this session. Override the default controlled by the configuration propertyhibernate.use_subselect_fetch.- Specified by:
setSubselectFetchingEnabledin interfaceMutiny.Session- Parameters:
enabled-trueto enable subselect fetching
-
setFlushMode
Description copied from interface:Mutiny.SessionSet theflush modefor 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.MANUALat the start of the session (in order to achieve some extra performance).- Specified by:
setFlushModein interfaceMutiny.Session- Parameters:
flushMode- the new flush mode
-
remove
Description copied from interface:Mutiny.SessionAsynchronously 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:
removein interfaceMutiny.Session- Parameters:
entity- the managed persistent instance to be removed- See Also:
-
EntityManager.remove(Object)
-
setCacheMode
Description copied from interface:Mutiny.SessionSet thecache modefor this session.The cache mode determines the manner in which this session interacts with the second level cache.
- Specified by:
setCacheModein interfaceMutiny.Session- Parameters:
cacheMode- The new cache mode.
-
enableFilter
Description copied from interface:Mutiny.SessionEnable the named filter for this session.- Specified by:
enableFilterin interfaceMutiny.Session- Parameters:
filterName- The name of the filter to be enabled.- Returns:
- The Filter instance representing the enabled filter.
-
createMutationQuery
Description copied from interface:Mutiny.QueryProducerCreate aMutiny.MutationQueryfrom the given insert select criteria tree- Specified by:
createMutationQueryin interfaceMutiny.QueryProducer- Parameters:
insert- the insert select criteria query- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.Queryfor the given SQL query string, or SQL update, insert, or delete statement. In the case of an update, insert, or delete, the returnedMutiny.Querymust be executed usingMutiny.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 entitiesare synchronized with the database before execution of the statement.- Specified by:
createNativeQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The SQL select, update, insert, or delete statementaffectedEntities- The entities which are affected by the statement
-
setReadOnly
Description copied from interface:Mutiny.SessionSet 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:
setReadOnlyin interfaceMutiny.Session- See Also:
-
createEntityGraph
Description copied from interface:Mutiny.QueryProducerCreate a new mutableEntityGraph- Specified by:
createEntityGraphin interfaceMutiny.QueryProducer
-
refreshAll
Description copied from interface:Mutiny.SessionRefresh multiple entity instances at once.- Specified by:
refreshAllin interfaceMutiny.Session- See Also:
-
createMutationQuery
public Mutiny.MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaDelete<?> deleteQuery) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.MutationQueryfor the given delete tree.- Specified by:
createMutationQueryin interfaceMutiny.QueryProducer- Parameters:
deleteQuery- the delete criteria query- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution - See Also:
-
getBatchSize
Description copied from interface:Mutiny.SessionThe session-level batch size, ornullif it has not been overridden.- Specified by:
getBatchSizein interfaceMutiny.Session
-
refresh
Description copied from interface:Mutiny.SessionRe-read the state of the given instance from the underlying database, requesting the givenLockMode.- Specified by:
refreshin interfaceMutiny.Session- Parameters:
entity- a managed persistent entity instancelockMode- the requested lock mode- See Also:
-
getReference
Description copied from interface:Mutiny.SessionReturn 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 usingMutiny.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:
getReferencein interfaceMutiny.Session- Parameters:
entityClass- a persistent classid- 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.SessionReturn 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 usingMutiny.Session.fetch(Object).- Specified by:
getReferencein interfaceMutiny.Session- Parameters:
entity- a detached persistent instance- Returns:
- the persistent instance or proxy
-
setBatchSize
Description copied from interface:Mutiny.SessionSet the session-level batch size, overriding the batch size set by the configuration propertyhibernate.jdbc.batch_size.- Specified by:
setBatchSizein interfaceMutiny.Session
-
refresh
Description copied from interface:Mutiny.SessionRe-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:
refreshin interfaceMutiny.Session- Parameters:
entity- a managed persistent instance- See Also:
-
EntityManager.refresh(Object)
-
getCacheMode
Description copied from interface:Mutiny.SessionGet the current cache mode.- Specified by:
getCacheModein interfaceMutiny.Session- Returns:
- The current cache mode.
-
mergeAll
Description copied from interface:Mutiny.SessionMerge multiple entity instances at once.- Specified by:
mergeAllin interfaceMutiny.Session- See Also:
-
persist
Description copied from interface:Mutiny.SessionAsynchronously 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:
persistin interfaceMutiny.Session- Parameters:
object- a transient instance of a persistent class- See Also:
-
EntityManager.persist(Object)
-
contains
Description copied from interface:Mutiny.SessionDetermine if the given instance belongs to this persistence context.- Specified by:
containsin interfaceMutiny.Session
-
createMutationQuery
public Mutiny.MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate<?> updateQuery) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.MutationQueryfor the given update tree.- Specified by:
createMutationQueryin interfaceMutiny.QueryProducer- Parameters:
updateQuery- the update criteria query- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution - See Also:
-
getFetchBatchSize
public int getFetchBatchSize()Description copied from interface:Mutiny.SessionGet the maximum batch size for batch fetching associations by id in this session.- Specified by:
getFetchBatchSizein interfaceMutiny.Session
-
setDefaultReadOnly
Description copied from interface:Mutiny.SessionChange 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:
setDefaultReadOnlyin interfaceMutiny.Session- See Also:
-
clear
Description copied from interface:Mutiny.SessionCompletely clear the session. Detach all persistent instances and cancel all pending insertions, updates and deletions.- Specified by:
clearin interfaceMutiny.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.SessionFetch a lazy property of the given entity, identified by a JPAattribute 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:
fetchin interfaceMutiny.Session
-
createQuery
public <R> Mutiny.SelectionQuery<R> createQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.SelectionQueryfor the given criteria query.- Specified by:
createQueryin interfaceMutiny.QueryProducer- Parameters:
criteriaQuery- TheCriteriaQuery- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
-
EntityManager.createQuery(String)
-
setCacheRetrieveMode
Description copied from interface:Mutiny.SessionSet theCacheRetrieveModefor this session.- Specified by:
setCacheRetrieveModein interfaceMutiny.Session- Parameters:
cacheRetrieveMode- The new cache retrieve mode.
-
removeAll
Description copied from interface:Mutiny.SessionRemove multiple entity instances at once.- Specified by:
removeAllin interfaceMutiny.Session- See Also:
-
getEnabledFilter
Description copied from interface:Mutiny.SessionRetrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceMutiny.Session- Parameters:
filterName- The name of the filter to be retrieved.- Returns:
- The Filter instance representing the enabled filter.
-
disableFilter
Description copied from interface:Mutiny.SessionDisable the named filter for this session.- Specified by:
disableFilterin interfaceMutiny.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.QueryProducerCreate an instance ofMutiny.MutationQueryfor the given criteria delete.- Specified by:
createQueryin interfaceMutiny.QueryProducer- Parameters:
criteriaDelete- TheCriteriaDelete- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution
-
enableFetchProfile
Description copied from interface:Mutiny.SessionEnable a particular fetch profile on this session, or do nothing if requested fetch profile is already enabled.- Specified by:
enableFetchProfilein interfaceMutiny.Session- Parameters:
name- The name of the fetch profile to be enabled.- See Also:
-
getResultSetMapping
Description copied from interface:Mutiny.QueryProducerObtain a native SQL result set mapping defined via the annotationSqlResultSetMapping.- Specified by:
getResultSetMappingin interfaceMutiny.QueryProducer
-
flush
Description copied from interface:Mutiny.SessionForce 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:
flushin interfaceMutiny.Session- See Also:
-
EntityManager.flush()
-
persist
Description copied from interface:Mutiny.SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.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:
persistin interfaceMutiny.Session- Parameters:
entityName- the entity nameobject- a transient instance to be made persistent- See Also:
-
createNativeQuery
Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.Queryfor the given SQL query string, or SQL update, insert, or delete statement. In the case of an update, insert, or delete, the returnedMutiny.Querymust be executed usingMutiny.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:
createNativeQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The SQL select, update, insert, or delete statement
-
isFetchProfileEnabled
Description copied from interface:Mutiny.SessionDetermine if the fetch profile with the given name is enabled for this session.- Specified by:
isFetchProfileEnabledin interfaceMutiny.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.SessionCopy 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:
mergein interfaceMutiny.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.SessionDetermine if subselect fetching is enabled in this session.- Specified by:
isSubselectFetchingEnabledin interfaceMutiny.Session- Returns:
trueif subselect fetching is enabled
-
createQuery
public <R> Mutiny.MutationQuery createQuery(jakarta.persistence.criteria.CriteriaUpdate<R> criteriaUpdate) Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.MutationQueryfor the given criteria update.- Specified by:
createQueryin interfaceMutiny.QueryProducer- Parameters:
criteriaUpdate- TheCriteriaUpdate- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution
-
setFetchBatchSize
Description copied from interface:Mutiny.SessionSet the maximum batch size for batch fetching associations by id in this session. Override the default controlled by the configuration propertyhibernate.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:
setFetchBatchSizein interfaceMutiny.Session- Parameters:
batchSize- the maximum batch size for batch fetching
- If
-
fetch
public <T> io.smallrye.mutiny.Uni<T> fetch(T association) Description copied from interface:Mutiny.SessionAsynchronously 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:
fetchin interfaceMutiny.Session- Parameters:
association- a lazy-loaded association, or a proxy- Returns:
- the fetched association, via a
Uni - See Also:
-
persistAll
Description copied from interface:Mutiny.SessionPersist multiple transient entity instances at once.- Specified by:
persistAllin interfaceMutiny.Session- See Also:
-
createQuery
Deprecated.Description copied from interface:Mutiny.QueryProducerCreate an instance ofMutiny.Queryfor the given HQL/JPQL query string or HQL/JPQL update or delete statement. In the case of an update or delete, the returnedMutiny.Querymust be executed usingMutiny.MutationQuery.executeUpdate()which returns an affected row count.- Specified by:
createQueryin interfaceMutiny.QueryProducer- Parameters:
queryString- The HQL/JPQL query, update or delete statement- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
-
EntityManager.createQuery(String)
-
setFlushMode
Description copied from interface:Mutiny.SessionSet theflush modefor 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:
setFlushModein interfaceMutiny.Session- Parameters:
flushModeType- the new flush mode
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceMutiny.Session- Returns:
- false if
Mutiny.Closeable.close()has been called
-