Class MutinyStatelessSessionDelegator
- java.lang.Object
-
- org.hibernate.reactive.mutiny.delegation.MutinyStatelessSessionDelegator
-
- All Implemented Interfaces:
Mutiny.Closeable,Mutiny.StatelessSession
public abstract class MutinyStatelessSessionDelegator extends Object implements Mutiny.StatelessSession
Wraps a delegate() stateless session.
-
-
Constructor Summary
Constructors Constructor Description MutinyStatelessSessionDelegator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<Void>close()Close the reactive session and release the underlying database connection.<T> EntityGraph<T>createEntityGraph(Class<T> rootType)Create a new mutableEntityGraph<T> EntityGraph<T>createEntityGraph(Class<T> rootType, String graphName)Create a new mutable copy of a namedEntityGraphMutiny.MutationQuerycreateMutationQuery(String queryString)Create an instance ofMutiny.MutationQueryfor the given HQL/JPQL update or delete statement.<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, ResultSetMapping<R> resultSetMapping)Create an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenResultSetMappingto interpret the result set.<R> Mutiny.SelectionQuery<R>createQuery(CriteriaQuery<R> criteriaQuery)Create an instance ofMutiny.SelectionQueryfor the given criteria query.<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.Mutiny.TransactioncurrentTransaction()Obtain the transaction currently associated with this session, if any.abstract Mutiny.StatelessSessiondelegate()io.smallrye.mutiny.Uni<Void>delete(Object entity)Delete a row.io.smallrye.mutiny.Uni<Void>deleteAll(int batchSize, Object... entities)Delete multiple rows.io.smallrye.mutiny.Uni<Void>deleteAll(Object... entities)Delete multiple rows.<T> io.smallrye.mutiny.Uni<T>fetch(T association)Asynchronously fetch an association that's configured for lazy loading.<T> io.smallrye.mutiny.Uni<T>get(EntityGraph<T> entityGraph, Object id)Retrieve a row, using the givenEntityGraphas a fetch plan.<T> io.smallrye.mutiny.Uni<T>get(Class<T> entityClass, Object id)Retrieve a row.<T> io.smallrye.mutiny.Uni<T>get(Class<T> entityClass, Object id, LockModeType lockModeType)Retrieve a row, obtaining the specified lock mode.<T> io.smallrye.mutiny.Uni<T>get(Class<T> entityClass, Object id, LockMode lockMode)Retrieve a row, obtaining the specified lock mode.<T> EntityGraph<T>getEntityGraph(Class<T> rootType, String graphName)Obtain a namedEntityGraphMutiny.SessionFactorygetFactory()TheMutiny.SessionFactorywhich created this session.<T> ResultSetMapping<T>getResultSetMapping(Class<T> resultType, String mappingName)Obtain a native SQL result set mapping defined via the annotationSqlResultSetMapping.io.smallrye.mutiny.Uni<Void>insert(Object entity)Insert a row.io.smallrye.mutiny.Uni<Void>insertAll(int batchSize, Object... entities)Insert multiple rows using the specified batch size.io.smallrye.mutiny.Uni<Void>insertAll(Object... entities)Insert multiple rows.booleanisOpen()io.smallrye.mutiny.Uni<Void>refresh(Object entity)Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<Void>refresh(Object entity, LockModeType lockModeType)Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<Void>refresh(Object entity, LockMode lockMode)Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<Void>refreshAll(int batchSize, Object... entities)Refresh the entity instance state from the database using the selected batch size.io.smallrye.mutiny.Uni<Void>refreshAll(Object... entities)Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<Void>update(Object entity)Update a row.io.smallrye.mutiny.Uni<Void>updateAll(int batchSize, Object... entities)Update multiple rows.io.smallrye.mutiny.Uni<Void>updateAll(Object... entities)Update multiple rows.io.smallrye.mutiny.Uni<Void>upsert(Object entity)Use a SQLmerge intostatement to perform an upsert.io.smallrye.mutiny.Uni<Void>upsert(String entityName, Object entity)Use a SQLmerge intostatement to perform an upsert.<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.
-
-
-
Method Detail
-
delegate
public abstract Mutiny.StatelessSession delegate()
-
get
public <T> io.smallrye.mutiny.Uni<T> get(Class<T> entityClass, Object id)
Description copied from interface:Mutiny.StatelessSessionRetrieve a row.- Specified by:
getin interfaceMutiny.StatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrieve- Returns:
- a detached entity instance, via a
Uni - See Also:
StatelessSession.get(Class, Object)
-
createQuery
@Deprecated public <R> Mutiny.Query<R> createQuery(String queryString)
Deprecated.Description copied from interface:Mutiny.StatelessSessionCreate 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.StatelessSession- Parameters:
queryString- The HQL/JPQL query, update or delete statement- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
Mutiny.Session.createQuery(String)
-
get
public <T> io.smallrye.mutiny.Uni<T> get(EntityGraph<T> entityGraph, Object id)
Description copied from interface:Mutiny.StatelessSessionRetrieve a row, using the givenEntityGraphas a fetch plan.- Specified by:
getin interfaceMutiny.StatelessSession- Parameters:
entityGraph- anEntityGraphspecifying the entity and associations to be fetchedid- The id of the entity to retrieve- Returns:
- a detached entity instance, via a
Uni
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenResultSetMappingto interpret the result set.- Specified by:
createNativeQueryin interfaceMutiny.StatelessSession- Parameters:
queryString- The SQL queryresultSetMapping- the result set mapping- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
Mutiny.Session.createNativeQuery(String, ResultSetMapping)
-
get
public <T> io.smallrye.mutiny.Uni<T> get(Class<T> entityClass, Object id, LockMode lockMode)
Description copied from interface:Mutiny.StatelessSessionRetrieve a row, obtaining the specified lock mode.- Specified by:
getin interfaceMutiny.StatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance, via a
Uni - See Also:
StatelessSession.get(Class, Object, LockMode)
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfaceMutiny.StatelessSession- Returns:
- false if
Mutiny.StatelessSession.close()has been called
-
insertAll
public io.smallrye.mutiny.Uni<Void> insertAll(Object... entities)
Description copied from interface:Mutiny.StatelessSessionInsert multiple rows.- Specified by:
insertAllin interfaceMutiny.StatelessSession- Parameters:
entities- new transient instances- See Also:
StatelessSession.insert(Object)
-
updateAll
public io.smallrye.mutiny.Uni<Void> updateAll(int batchSize, Object... entities)
Description copied from interface:Mutiny.StatelessSessionUpdate multiple rows.- Specified by:
updateAllin interfaceMutiny.StatelessSession- Parameters:
batchSize- the batch sizeentities- detached entity instances- See Also:
StatelessSession.update(Object)
-
createEntityGraph
public <T> EntityGraph<T> createEntityGraph(Class<T> rootType, String graphName)
Description copied from interface:Mutiny.StatelessSessionCreate a new mutable copy of a namedEntityGraph- Specified by:
createEntityGraphin interfaceMutiny.StatelessSession
-
getEntityGraph
public <T> EntityGraph<T> getEntityGraph(Class<T> rootType, String graphName)
Description copied from interface:Mutiny.StatelessSessionObtain a namedEntityGraph- Specified by:
getEntityGraphin interfaceMutiny.StatelessSession
-
get
public <T> io.smallrye.mutiny.Uni<T> get(Class<T> entityClass, Object id, LockModeType lockModeType)
Description copied from interface:Mutiny.StatelessSessionRetrieve a row, obtaining the specified lock mode.- Specified by:
getin interfaceMutiny.StatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrievelockModeType- The lock mode to apply to the entity- Returns:
- a detached entity instance, via a
Uni - See Also:
StatelessSession.get(Class, Object, LockMode)
-
update
public io.smallrye.mutiny.Uni<Void> update(Object entity)
Description copied from interface:Mutiny.StatelessSessionUpdate a row.- Specified by:
updatein interfaceMutiny.StatelessSession- Parameters:
entity- a detached entity instance- See Also:
StatelessSession.update(Object)
-
refreshAll
public io.smallrye.mutiny.Uni<Void> refreshAll(int batchSize, Object... entities)
Description copied from interface:Mutiny.StatelessSessionRefresh the entity instance state from the database using the selected batch size.- Specified by:
refreshAllin interfaceMutiny.StatelessSession- Parameters:
batchSize- the batch sizeentities- The entities to be refreshed.- See Also:
StatelessSession.refresh(Object)
-
createQuery
public <R> Mutiny.SelectionQuery<R> createQuery(String queryString, Class<R> resultType)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.SelectionQueryfor the given HQL/JPQL query string and query result type.- Specified by:
createQueryin interfaceMutiny.StatelessSession- Parameters:
queryString- The HQL/JPQL queryresultType- the Java type returned in each row of query results- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
Mutiny.Session.createQuery(String, Class)
-
delete
public io.smallrye.mutiny.Uni<Void> delete(Object entity)
Description copied from interface:Mutiny.StatelessSessionDelete a row.- Specified by:
deletein interfaceMutiny.StatelessSession- Parameters:
entity- a detached entity instance- See Also:
StatelessSession.delete(Object)
-
refresh
public io.smallrye.mutiny.Uni<Void> refresh(Object entity, LockModeType lockModeType)
Description copied from interface:Mutiny.StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceMutiny.StatelessSession- Parameters:
entity- The entity to be refreshed.lockModeType- The LockMode to be applied.- See Also:
StatelessSession.refresh(Object, LockMode)
-
getFactory
public Mutiny.SessionFactory getFactory()
Description copied from interface:Mutiny.StatelessSessionTheMutiny.SessionFactorywhich created this session.- Specified by:
getFactoryin interfaceMutiny.StatelessSession
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, Class<R> resultType)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.SelectionQueryfor the given SQL query string, using the givenresultTypeto interpret the results.- Specified by:
createNativeQueryin interfaceMutiny.StatelessSession- Parameters:
queryString- The SQL queryresultType- the Java type returned in each row of query results- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
Mutiny.Session.createNativeQuery(String, Class)
-
deleteAll
public io.smallrye.mutiny.Uni<Void> deleteAll(Object... entities)
Description copied from interface:Mutiny.StatelessSessionDelete multiple rows.- Specified by:
deleteAllin interfaceMutiny.StatelessSession- Parameters:
entities- detached entity instances- See Also:
StatelessSession.delete(Object)
-
createSelectionQuery
public <R> Mutiny.SelectionQuery<R> createSelectionQuery(String queryString, Class<R> resultType)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.SelectionQueryfor the given HQL/JPQL query string.- Specified by:
createSelectionQueryin interfaceMutiny.StatelessSession- Parameters:
queryString- The HQL/JPQL query- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String, Class)
-
upsert
@Incubating public io.smallrye.mutiny.Uni<Void> upsert(Object entity)
Description copied from interface:Mutiny.StatelessSessionUse a SQLmerge intostatement to perform an upsert.- Specified by:
upsertin interfaceMutiny.StatelessSession- Parameters:
entity- a detached entity instance- See Also:
StatelessSession.upsert(Object)
-
createMutationQuery
public Mutiny.MutationQuery createMutationQuery(String queryString)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.MutationQueryfor the given HQL/JPQL update or delete statement.- Specified by:
createMutationQueryin interfaceMutiny.StatelessSession- Parameters:
queryString- The HQL/JPQL query, update or delete statement- Returns:
- The
Mutiny.MutationQueryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
refresh
public io.smallrye.mutiny.Uni<Void> refresh(Object entity)
Description copied from interface:Mutiny.StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceMutiny.StatelessSession- Parameters:
entity- The entity to be refreshed.- See Also:
StatelessSession.refresh(Object)
-
getResultSetMapping
public <T> ResultSetMapping<T> getResultSetMapping(Class<T> resultType, String mappingName)
Description copied from interface:Mutiny.StatelessSessionObtain a native SQL result set mapping defined via the annotationSqlResultSetMapping.- Specified by:
getResultSetMappingin interfaceMutiny.StatelessSession
-
insertAll
public io.smallrye.mutiny.Uni<Void> insertAll(int batchSize, Object... entities)
Description copied from interface:Mutiny.StatelessSessionInsert multiple rows using the specified batch size.- Specified by:
insertAllin interfaceMutiny.StatelessSession- Parameters:
batchSize- the batch sizeentities- new transient instances- See Also:
StatelessSession.insert(Object)
-
createNativeQuery
public <R> Mutiny.Query<R> createNativeQuery(String queryString)
Description copied from interface:Mutiny.StatelessSessionCreate 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.- Specified by:
createNativeQueryin interfaceMutiny.StatelessSession- Parameters:
queryString- The SQL select, update, insert, or delete statement- See Also:
Mutiny.Session.createNativeQuery(String)
-
createNamedQuery
public <R> Mutiny.Query<R> createNamedQuery(String queryName)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.Queryfor the named query.- Specified by:
createNamedQueryin interfaceMutiny.StatelessSession- Parameters:
queryName- The name of the query- Returns:
- The
Mutiny.Queryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
createNamedQuery
public <R> Mutiny.SelectionQuery<R> createNamedQuery(String queryName, Class<R> resultType)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.SelectionQueryfor the named query.- Specified by:
createNamedQueryin interfaceMutiny.StatelessSession- 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)
-
refreshAll
public io.smallrye.mutiny.Uni<Void> refreshAll(Object... entities)
Description copied from interface:Mutiny.StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshAllin interfaceMutiny.StatelessSession- Parameters:
entities- The entities to be refreshed.- See Also:
StatelessSession.refresh(Object)
-
close
public io.smallrye.mutiny.Uni<Void> close()
Description copied from interface:Mutiny.StatelessSessionClose the reactive session and release the underlying database connection.- Specified by:
closein interfaceMutiny.Closeable- Specified by:
closein interfaceMutiny.StatelessSession
-
updateAll
public io.smallrye.mutiny.Uni<Void> updateAll(Object... entities)
Description copied from interface:Mutiny.StatelessSessionUpdate multiple rows.- Specified by:
updateAllin interfaceMutiny.StatelessSession- Parameters:
entities- detached entity instances- See Also:
StatelessSession.update(Object)
-
createQuery
public <R> Mutiny.SelectionQuery<R> createQuery(CriteriaQuery<R> criteriaQuery)
Description copied from interface:Mutiny.StatelessSessionCreate an instance ofMutiny.SelectionQueryfor the given criteria query.- Specified by:
createQueryin interfaceMutiny.StatelessSession- Parameters:
criteriaQuery- TheCriteriaQuery- Returns:
- The
Mutiny.SelectionQueryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
withTransaction
public <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Description copied from interface:Mutiny.StatelessSessionPerforms 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.- 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.StatelessSession- Parameters:
work- a function which acceptsMutiny.Transactionand returns the result of the work as aUni.- See Also:
Mutiny.SessionFactory.withTransaction(BiFunction)
-
fetch
public <T> io.smallrye.mutiny.Uni<T> fetch(T association)
Description copied from interface:Mutiny.StatelessSessionAsynchronously 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:
fetchin interfaceMutiny.StatelessSession- Parameters:
association- a lazy-loaded association- Returns:
- the fetched association, via a
Uni - See Also:
Hibernate.initialize(Object)
-
upsert
@Incubating public io.smallrye.mutiny.Uni<Void> upsert(String entityName, Object entity)
Description copied from interface:Mutiny.StatelessSessionUse a SQLmerge intostatement to perform an upsert.- Specified by:
upsertin interfaceMutiny.StatelessSession- Parameters:
entityName- The entityName for the entity to be mergedentity- a detached entity instance- See Also:
StatelessSession.upsert(String, Object)
-
currentTransaction
@Incubating public Mutiny.Transaction currentTransaction()
Description copied from interface:Mutiny.StatelessSessionObtain the transaction currently associated with this session, if any.- Specified by:
currentTransactionin interfaceMutiny.StatelessSession- Returns:
- the
Mutiny.Transaction, or null if no transaction was started usingMutiny.StatelessSession.withTransaction(Function). - See Also:
Mutiny.StatelessSession.withTransaction(Function),Mutiny.SessionFactory.withTransaction(BiFunction)
-
createEntityGraph
public <T> EntityGraph<T> createEntityGraph(Class<T> rootType)
Description copied from interface:Mutiny.StatelessSessionCreate a new mutableEntityGraph- Specified by:
createEntityGraphin interfaceMutiny.StatelessSession
-
insert
public io.smallrye.mutiny.Uni<Void> insert(Object entity)
Description copied from interface:Mutiny.StatelessSessionInsert a row.- Specified by:
insertin interfaceMutiny.StatelessSession- Parameters:
entity- a new transient instance- See Also:
StatelessSession.insert(Object)
-
refresh
public io.smallrye.mutiny.Uni<Void> refresh(Object entity, LockMode lockMode)
Description copied from interface:Mutiny.StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceMutiny.StatelessSession- Parameters:
entity- The entity to be refreshed.lockMode- The LockMode to be applied.- See Also:
StatelessSession.refresh(Object, LockMode)
-
deleteAll
public io.smallrye.mutiny.Uni<Void> deleteAll(int batchSize, Object... entities)
Description copied from interface:Mutiny.StatelessSessionDelete multiple rows.- Specified by:
deleteAllin interfaceMutiny.StatelessSession- Parameters:
batchSize- the batch sizeentities- detached entity instances- See Also:
StatelessSession.delete(Object)
-
-