Class MutinyStatelessSessionImpl
- java.lang.Object
-
- org.hibernate.reactive.mutiny.impl.MutinyStatelessSessionImpl
-
- All Implemented Interfaces:
Mutiny.Closeable
,Mutiny.StatelessSession
public class MutinyStatelessSessionImpl extends java.lang.Object implements Mutiny.StatelessSession
Implements theMutiny.StatelessSession
API. This delegating class is needed to avoid name clashes when implementing bothStatelessSession
andStatelessSession
.
-
-
Constructor Summary
Constructors Constructor Description MutinyStatelessSessionImpl(ReactiveStatelessSession delegate, MutinySessionFactoryImpl factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.smallrye.mutiny.Uni<java.lang.Void>
close()
Close the reactive session and release the underlying database connection.<T> jakarta.persistence.EntityGraph<T>
createEntityGraph(java.lang.Class<T> rootType)
Create a new mutableEntityGraph
<T> jakarta.persistence.EntityGraph<T>
createEntityGraph(java.lang.Class<T> rootType, java.lang.String graphName)
Create a new mutable copy of a namedEntityGraph
<R> Mutiny.Query<R>
createNamedQuery(java.lang.String queryName)
Create an instance ofMutiny.Query
for the named query.<R> Mutiny.SelectionQuery<R>
createNamedQuery(java.lang.String queryName, java.lang.Class<R> resultType)
Create an instance ofMutiny.SelectionQuery
for the named query.<R> Mutiny.Query<R>
createNativeQuery(java.lang.String queryString)
Create an instance ofMutiny.Query
for the given SQL query string, or SQL update, insert, or delete statement.<R> Mutiny.SelectionQuery<R>
createNativeQuery(java.lang.String queryString, java.lang.Class<R> resultType)
Create an instance ofMutiny.SelectionQuery
for the given SQL query string, using the givenresultType
to interpret the results.<R> Mutiny.SelectionQuery<R>
createNativeQuery(java.lang.String queryString, ResultSetMapping<R> resultSetMapping)
Create an instance ofMutiny.SelectionQuery
for the given SQL query string, using the givenResultSetMapping
to interpret the result set.<R> Mutiny.SelectionQuery<R>
createQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery)
Create an instance ofMutiny.SelectionQuery
for the given criteria query.<R> Mutiny.Query<R>
createQuery(java.lang.String queryString)
Create an instance ofMutiny.Query
for the given HQL/JPQL query string or HQL/JPQL update or delete statement.<R> Mutiny.SelectionQuery<R>
createQuery(java.lang.String queryString, java.lang.Class<R> resultType)
Create an instance ofMutiny.SelectionQuery
for the given HQL/JPQL query string and query result type.Mutiny.Transaction
currentTransaction()
Obtain the transaction currently associated with this session, if any.io.smallrye.mutiny.Uni<java.lang.Void>
delete(java.lang.Object entity)
Delete a row.io.smallrye.mutiny.Uni<java.lang.Void>
deleteAll(int batchSize, java.lang.Object... entities)
Delete multiple rows.io.smallrye.mutiny.Uni<java.lang.Void>
deleteAll(java.lang.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(jakarta.persistence.EntityGraph<T> entityGraph, java.lang.Object id)
Retrieve a row, using the givenEntityGraph
as a fetch plan.<T> io.smallrye.mutiny.Uni<T>
get(java.lang.Class<T> entityClass, java.lang.Object id)
Retrieve a row.<T> io.smallrye.mutiny.Uni<T>
get(java.lang.Class<T> entityClass, java.lang.Object id, org.hibernate.LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.<T> jakarta.persistence.EntityGraph<T>
getEntityGraph(java.lang.Class<T> rootType, java.lang.String graphName)
Obtain a namedEntityGraph
ReactiveConnection
getReactiveConnection()
<T> ResultSetMapping<T>
getResultSetMapping(java.lang.Class<T> resultType, java.lang.String mappingName)
Obtain a native SQL result set mapping defined via the annotationSqlResultSetMapping
.io.smallrye.mutiny.Uni<java.lang.Void>
insert(java.lang.Object entity)
Insert a row.io.smallrye.mutiny.Uni<java.lang.Void>
insertAll(int batchSize, java.lang.Object... entities)
Insert multiple rows using the specified batch size.io.smallrye.mutiny.Uni<java.lang.Void>
insertAll(java.lang.Object... entities)
Insert multiple rows.boolean
isOpen()
io.smallrye.mutiny.Uni<java.lang.Void>
refresh(java.lang.Object entity)
Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<java.lang.Void>
refresh(java.lang.Object entity, org.hibernate.LockMode lockMode)
Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<java.lang.Void>
refreshAll(int batchSize, java.lang.Object... entities)
Refresh the entity instance state from the database using the selected batch size.io.smallrye.mutiny.Uni<java.lang.Void>
refreshAll(java.lang.Object... entities)
Refresh the entity instance state from the database.io.smallrye.mutiny.Uni<java.lang.Void>
update(java.lang.Object entity)
Update a row.io.smallrye.mutiny.Uni<java.lang.Void>
updateAll(int batchSize, java.lang.Object... entities)
Update multiple rows.io.smallrye.mutiny.Uni<java.lang.Void>
updateAll(java.lang.Object... entities)
Update multiple rows.<T> io.smallrye.mutiny.Uni<T>
withTransaction(java.util.function.Function<Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Performs the given work within the scope of a database transaction, automatically flushing the session.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.reactive.mutiny.Mutiny.StatelessSession
get, refresh
-
-
-
-
Constructor Detail
-
MutinyStatelessSessionImpl
public MutinyStatelessSessionImpl(ReactiveStatelessSession delegate, MutinySessionFactoryImpl factory)
-
-
Method Detail
-
getReactiveConnection
public ReactiveConnection getReactiveConnection()
-
get
public <T> io.smallrye.mutiny.Uni<T> get(java.lang.Class<T> entityClass, java.lang.Object id)
Description copied from interface:Mutiny.StatelessSession
Retrieve a row.- Specified by:
get
in 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)
-
get
public <T> io.smallrye.mutiny.Uni<T> get(java.lang.Class<T> entityClass, java.lang.Object id, org.hibernate.LockMode lockMode)
Description copied from interface:Mutiny.StatelessSession
Retrieve a row, obtaining the specified lock mode.- Specified by:
get
in 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)
-
get
public <T> io.smallrye.mutiny.Uni<T> get(jakarta.persistence.EntityGraph<T> entityGraph, java.lang.Object id)
Description copied from interface:Mutiny.StatelessSession
Retrieve a row, using the givenEntityGraph
as a fetch plan.- Specified by:
get
in interfaceMutiny.StatelessSession
- Parameters:
entityGraph
- anEntityGraph
specifying the entity and associations to be fetchedid
- The id of the entity to retrieve- Returns:
- a detached entity instance, via a
Uni
-
createQuery
public <R> Mutiny.Query<R> createQuery(java.lang.String queryString)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.Query
for the given HQL/JPQL query string or HQL/JPQL update or delete statement. In the case of an update or delete, the returnedMutiny.Query
must be executed usingMutiny.MutationQuery.executeUpdate()
which returns an affected row count.- Specified by:
createQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryString
- The HQL/JPQL query, update or delete statement- Returns:
- The
Mutiny.Query
instance for manipulation and execution - See Also:
Mutiny.Session.createQuery(String)
-
createQuery
public <R> Mutiny.SelectionQuery<R> createQuery(java.lang.String queryString, java.lang.Class<R> resultType)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.SelectionQuery
for the given HQL/JPQL query string and query result type.- Specified by:
createQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryString
- The HQL/JPQL queryresultType
- the Java type returned in each row of query results- Returns:
- The
Mutiny.Query
instance for manipulation and execution - See Also:
Mutiny.Session.createQuery(String, Class)
-
createNamedQuery
public <R> Mutiny.Query<R> createNamedQuery(java.lang.String queryName)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.Query
for the named query.- Specified by:
createNamedQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryName
- The name of the query- Returns:
- The
Mutiny.Query
instance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
createNamedQuery
public <R> Mutiny.SelectionQuery<R> createNamedQuery(java.lang.String queryName, java.lang.Class<R> resultType)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.SelectionQuery
for the named query.- Specified by:
createNamedQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryName
- The name of the queryresultType
- 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)
-
createNativeQuery
public <R> Mutiny.Query<R> createNativeQuery(java.lang.String queryString)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.Query
for the given SQL query string, or SQL update, insert, or delete statement. In the case of an update, insert, or delete, the returnedMutiny.Query
must be executed usingMutiny.MutationQuery.executeUpdate()
which returns an affected row count.- Specified by:
createNativeQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryString
- The SQL select, update, insert, or delete statement- See Also:
Mutiny.Session.createNativeQuery(String)
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(java.lang.String queryString, java.lang.Class<R> resultType)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.SelectionQuery
for the given SQL query string, using the givenresultType
to interpret the results.- Specified by:
createNativeQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryString
- The SQL queryresultType
- the Java type returned in each row of query results- Returns:
- The
Mutiny.Query
instance for manipulation and execution - See Also:
Mutiny.Session.createNativeQuery(String, Class)
-
createNativeQuery
public <R> Mutiny.SelectionQuery<R> createNativeQuery(java.lang.String queryString, ResultSetMapping<R> resultSetMapping)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.SelectionQuery
for the given SQL query string, using the givenResultSetMapping
to interpret the result set.- Specified by:
createNativeQuery
in interfaceMutiny.StatelessSession
- Parameters:
queryString
- The SQL queryresultSetMapping
- the result set mapping- Returns:
- The
Mutiny.Query
instance for manipulation and execution - See Also:
Mutiny.Session.createNativeQuery(String, ResultSetMapping)
-
createQuery
public <R> Mutiny.SelectionQuery<R> createQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery)
Description copied from interface:Mutiny.StatelessSession
Create an instance ofMutiny.SelectionQuery
for the given criteria query.- Specified by:
createQuery
in interfaceMutiny.StatelessSession
- Parameters:
criteriaQuery
- TheCriteriaQuery
- Returns:
- The
Mutiny.SelectionQuery
instance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
insert
public io.smallrye.mutiny.Uni<java.lang.Void> insert(java.lang.Object entity)
Description copied from interface:Mutiny.StatelessSession
Insert a row.- Specified by:
insert
in interfaceMutiny.StatelessSession
- Parameters:
entity
- a new transient instance- See Also:
StatelessSession.insert(Object)
-
insertAll
public io.smallrye.mutiny.Uni<java.lang.Void> insertAll(java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Insert multiple rows.- Specified by:
insertAll
in interfaceMutiny.StatelessSession
- Parameters:
entities
- new transient instances- See Also:
StatelessSession.insert(Object)
-
insertAll
public io.smallrye.mutiny.Uni<java.lang.Void> insertAll(int batchSize, java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Insert multiple rows using the specified batch size.- Specified by:
insertAll
in interfaceMutiny.StatelessSession
- Parameters:
batchSize
- the batch sizeentities
- new transient instances- See Also:
StatelessSession.insert(Object)
-
delete
public io.smallrye.mutiny.Uni<java.lang.Void> delete(java.lang.Object entity)
Description copied from interface:Mutiny.StatelessSession
Delete a row.- Specified by:
delete
in interfaceMutiny.StatelessSession
- Parameters:
entity
- a detached entity instance- See Also:
StatelessSession.delete(Object)
-
deleteAll
public io.smallrye.mutiny.Uni<java.lang.Void> deleteAll(java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Delete multiple rows.- Specified by:
deleteAll
in interfaceMutiny.StatelessSession
- Parameters:
entities
- detached entity instances- See Also:
StatelessSession.delete(Object)
-
deleteAll
public io.smallrye.mutiny.Uni<java.lang.Void> deleteAll(int batchSize, java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Delete multiple rows.- Specified by:
deleteAll
in interfaceMutiny.StatelessSession
- Parameters:
batchSize
- the batch sizeentities
- detached entity instances- See Also:
StatelessSession.delete(Object)
-
update
public io.smallrye.mutiny.Uni<java.lang.Void> update(java.lang.Object entity)
Description copied from interface:Mutiny.StatelessSession
Update a row.- Specified by:
update
in interfaceMutiny.StatelessSession
- Parameters:
entity
- a detached entity instance- See Also:
StatelessSession.update(Object)
-
updateAll
public io.smallrye.mutiny.Uni<java.lang.Void> updateAll(java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Update multiple rows.- Specified by:
updateAll
in interfaceMutiny.StatelessSession
- Parameters:
entities
- detached entity instances- See Also:
StatelessSession.update(Object)
-
updateAll
public io.smallrye.mutiny.Uni<java.lang.Void> updateAll(int batchSize, java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Update multiple rows.- Specified by:
updateAll
in interfaceMutiny.StatelessSession
- Parameters:
batchSize
- the batch sizeentities
- detached entity instances- See Also:
StatelessSession.update(Object)
-
refresh
public io.smallrye.mutiny.Uni<java.lang.Void> refresh(java.lang.Object entity)
Description copied from interface:Mutiny.StatelessSession
Refresh the entity instance state from the database.- Specified by:
refresh
in interfaceMutiny.StatelessSession
- Parameters:
entity
- The entity to be refreshed.- See Also:
StatelessSession.refresh(Object)
-
refreshAll
public io.smallrye.mutiny.Uni<java.lang.Void> refreshAll(java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Refresh the entity instance state from the database.- Specified by:
refreshAll
in interfaceMutiny.StatelessSession
- Parameters:
entities
- The entities to be refreshed.- See Also:
StatelessSession.refresh(Object)
-
refreshAll
public io.smallrye.mutiny.Uni<java.lang.Void> refreshAll(int batchSize, java.lang.Object... entities)
Description copied from interface:Mutiny.StatelessSession
Refresh the entity instance state from the database using the selected batch size.- Specified by:
refreshAll
in interfaceMutiny.StatelessSession
- Parameters:
batchSize
- the batch sizeentities
- The entities to be refreshed.- See Also:
StatelessSession.refresh(Object)
-
refresh
public io.smallrye.mutiny.Uni<java.lang.Void> refresh(java.lang.Object entity, org.hibernate.LockMode lockMode)
Description copied from interface:Mutiny.StatelessSession
Refresh the entity instance state from the database.- Specified by:
refresh
in interfaceMutiny.StatelessSession
- Parameters:
entity
- The entity to be refreshed.lockMode
- The LockMode to be applied.- See Also:
StatelessSession.refresh(Object, LockMode)
-
fetch
public <T> io.smallrye.mutiny.Uni<T> fetch(T association)
Description copied from interface:Mutiny.StatelessSession
Asynchronously fetch an association that's configured for lazy loading.session.fetch(author.getBook()).thenAccept(book -> print(book.getTitle()))
Warning: this operation in a stateless session is quite sensitive to data aliasing effects and should be used with great care.
- Specified by:
fetch
in interfaceMutiny.StatelessSession
- Parameters:
association
- a lazy-loaded association- Returns:
- the fetched association, via a
Uni
- See Also:
Hibernate.initialize(Object)
-
withTransaction
public <T> io.smallrye.mutiny.Uni<T> withTransaction(java.util.function.Function<Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Description copied from interface:Mutiny.StatelessSession
Performs the given work within the scope of a database transaction, automatically flushing the session. The transaction will be rolled back if the work completes with an uncaught exception, or 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:
withTransaction
in interfaceMutiny.StatelessSession
- Parameters:
work
- a function which acceptsMutiny.Transaction
and returns the result of the work as aUni
.- See Also:
Mutiny.SessionFactory.withTransaction(BiFunction)
-
currentTransaction
public Mutiny.Transaction currentTransaction()
Description copied from interface:Mutiny.StatelessSession
Obtain the transaction currently associated with this session, if any.- Specified by:
currentTransaction
in 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)
-
close
public io.smallrye.mutiny.Uni<java.lang.Void> close()
Description copied from interface:Mutiny.StatelessSession
Close the reactive session and release the underlying database connection.- Specified by:
close
in interfaceMutiny.Closeable
- Specified by:
close
in interfaceMutiny.StatelessSession
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceMutiny.StatelessSession
- Returns:
- false if
Mutiny.StatelessSession.close()
has been called
-
getResultSetMapping
public <T> ResultSetMapping<T> getResultSetMapping(java.lang.Class<T> resultType, java.lang.String mappingName)
Description copied from interface:Mutiny.StatelessSession
Obtain a native SQL result set mapping defined via the annotationSqlResultSetMapping
.- Specified by:
getResultSetMapping
in interfaceMutiny.StatelessSession
-
getEntityGraph
public <T> jakarta.persistence.EntityGraph<T> getEntityGraph(java.lang.Class<T> rootType, java.lang.String graphName)
Description copied from interface:Mutiny.StatelessSession
Obtain a namedEntityGraph
- Specified by:
getEntityGraph
in interfaceMutiny.StatelessSession
-
createEntityGraph
public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(java.lang.Class<T> rootType)
Description copied from interface:Mutiny.StatelessSession
Create a new mutableEntityGraph
- Specified by:
createEntityGraph
in interfaceMutiny.StatelessSession
-
createEntityGraph
public <T> jakarta.persistence.EntityGraph<T> createEntityGraph(java.lang.Class<T> rootType, java.lang.String graphName)
Description copied from interface:Mutiny.StatelessSession
Create a new mutable copy of a namedEntityGraph
- Specified by:
createEntityGraph
in interfaceMutiny.StatelessSession
-
-