Interface Mutiny.SessionFactory
-
- All Superinterfaces:
AutoCloseable
- Enclosing interface:
- Mutiny
public static interface Mutiny.SessionFactory extends AutoCloseable
Factory forreactive sessions
.A
Mutiny.SessionFactory
may be obtained from an instance ofEntityManagerFactory
as follows:Mutiny.SessionFactory sessionFactory = createEntityManagerFactory("example") .unwrap(Mutiny.SessionFactory.class);
Here, configuration properties must be specified in
persistence.xml
.Alternatively, a
Mutiny.SessionFactory
may be obtained via programmatic configuration of Hibernate using:Configuration configuration = new Configuration(); ... Mutiny.SessionFactory sessionFactory = configuration.buildSessionFactory( new ReactiveServiceRegistryBuilder() .applySettings( configuration.getProperties() ) .build() ) .unwrap(Mutiny.SessionFactory.class);
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Destroy the session factory and clean up its connection pool.Cache
getCache()
Obtain theCache
object for managing the second-level cache.jakarta.persistence.criteria.CriteriaBuilder
getCriteriaBuilder()
jakarta.persistence.metamodel.Metamodel
getMetamodel()
Obtain the JPAMetamodel
for the persistence unit.Statistics
getStatistics()
Obtain theStatistics
object exposing factory-level metrics.boolean
isOpen()
io.smallrye.mutiny.Uni<Mutiny.Session>
openSession()
Obtain a newreactive session
Uni
, the main interaction point between the user's program and Hibernate Reactive.io.smallrye.mutiny.Uni<Mutiny.Session>
openSession(String tenantId)
Obtain a newreactive session
Uni
for a specified tenant.io.smallrye.mutiny.Uni<Mutiny.StatelessSession>
openStatelessSession()
Obtain areactive stateless session
Uni
.io.smallrye.mutiny.Uni<Mutiny.StatelessSession>
openStatelessSession(String tenantId)
Obtain areactive stateless session
Uni
.<T> io.smallrye.mutiny.Uni<T>
withSession(String tenantId, Function<Mutiny.Session,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
for a specified tenant.<T> io.smallrye.mutiny.Uni<T>
withSession(Function<Mutiny.Session,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
.<T> io.smallrye.mutiny.Uni<T>
withStatelessSession(String tenantId, Function<Mutiny.StatelessSession,io.smallrye.mutiny.Uni<T>> work)
Perform work using astateless session
.<T> io.smallrye.mutiny.Uni<T>
withStatelessSession(Function<Mutiny.StatelessSession,io.smallrye.mutiny.Uni<T>> work)
Perform work using astateless session
.<T> io.smallrye.mutiny.Uni<T>
withStatelessTransaction(String tenantId, BiFunction<Mutiny.StatelessSession,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
for a specified tenant within an associatedtransaction
.<T> io.smallrye.mutiny.Uni<T>
withStatelessTransaction(BiFunction<Mutiny.StatelessSession,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associatedtransaction
.default <T> io.smallrye.mutiny.Uni<T>
withStatelessTransaction(Function<Mutiny.StatelessSession,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associatedtransaction
.<T> io.smallrye.mutiny.Uni<T>
withTransaction(String tenantId, BiFunction<Mutiny.Session,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
for a specified tenant within an associatedtransaction
.<T> io.smallrye.mutiny.Uni<T>
withTransaction(BiFunction<Mutiny.Session,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associatedtransaction
.default <T> io.smallrye.mutiny.Uni<T>
withTransaction(Function<Mutiny.Session,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associated transaction.
-
-
-
Method Detail
-
openSession
io.smallrye.mutiny.Uni<Mutiny.Session> openSession()
Obtain a newreactive session
Uni
, the main interaction point between the user's program and Hibernate Reactive.When the
Uni
completes successfully it returns a newly created session.The client must explicitly close the session by calling
Mutiny.Closeable.close()
.- See Also:
withSession(Function)
-
openSession
io.smallrye.mutiny.Uni<Mutiny.Session> openSession(String tenantId)
Obtain a newreactive session
Uni
for a specified tenant.When the
Uni
completes successfully it returns a newly created session.The client must explicitly close the session by calling
Mutiny.Closeable.close()
.- Parameters:
tenantId
- the id of the tenant- See Also:
withSession(Function)
-
openStatelessSession
io.smallrye.mutiny.Uni<Mutiny.StatelessSession> openStatelessSession()
Obtain areactive stateless session
Uni
.When the
Uni
completes successfully it returns a newly created session.The client must explicitly close the session by calling
Mutiny.StatelessSession.close()
.- See Also:
withStatelessSession(Function)
-
openStatelessSession
io.smallrye.mutiny.Uni<Mutiny.StatelessSession> openStatelessSession(String tenantId)
Obtain areactive stateless session
Uni
.When the
Uni
completes successfully it returns a newly created session.The client must explicitly close the session by calling
Mutiny.StatelessSession.close()
.- Parameters:
tenantId
- the id of the tenant- See Also:
withStatelessSession(String, Function)
-
withSession
<T> io.smallrye.mutiny.Uni<T> withSession(Function<Mutiny.Session,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
.- If there is already a session associated with the current reactive stream, then the work will be executed using that session.
- Otherwise, if there is no session associated with the current stream, a new session will be created.
The session will be closed automatically, but must be flushed explicitly if necessary.
- Parameters:
work
- a function which accepts the session and returns the result of the work as aUni
.
-
withSession
<T> io.smallrye.mutiny.Uni<T> withSession(String tenantId, Function<Mutiny.Session,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
for a specified tenant.- If there is already a session associated with the current reactive stream, and the given tenant, then the work will be executed using that session.
- Otherwise, a new session will be created.
The session will be closed automatically, but must be flushed explicitly if necessary.
- Parameters:
tenantId
- the id of the tenantwork
- a function which accepts the session and returns the result of the work as aUni
.
-
withTransaction
<T> io.smallrye.mutiny.Uni<T> withTransaction(BiFunction<Mutiny.Session,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associatedtransaction
.- If there is already a session associated with the current reactive stream, then the work will be executed using that session.
- Otherwise, if there is no session associated with the current stream, a new session will be created.
The session will be
flushed
and closed automatically, and the transaction committed automatically.- Parameters:
work
- a function which accepts the session and transaction and returns the result of the work as aUni
.- See Also:
withSession(Function)
,Mutiny.Session.withTransaction(Function)
-
withTransaction
default <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<Mutiny.Session,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associated transaction.- If there is already a session associated with the current reactive stream, then the work will be executed using that session.
- Otherwise, if there is no session associated with the current stream, a new session will be created.
The session will be
flushed
and closed automatically, and the transaction committed automatically.- Parameters:
work
- a function which accepts the session and returns the result of the work as aUni
.- See Also:
withTransaction(BiFunction)
,Mutiny.Session.withTransaction(Function)
-
withStatelessTransaction
default <T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(Function<Mutiny.StatelessSession,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associatedtransaction
.- If there is already a stateless session associated with the current reactive stream, then the work will be executed using that session.
- Otherwise, if there is no stateless session associated with the current stream, a new stateless session will be created.
The session will be closed automatically and the transaction committed automatically.
- Parameters:
work
- a function which accepts the stateless session and returns the result of the work as aUni
.- See Also:
withStatelessSession(Function)
,Mutiny.StatelessSession.withTransaction(Function)
-
withStatelessTransaction
<T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(BiFunction<Mutiny.StatelessSession,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
within an associatedtransaction
.- If there is already a stateless session associated with the current reactive stream, then the work will be executed using that session.
- Otherwise, if there is no stateless session associated with the current stream, a new stateless session will be created.
The session will be closed automatically and the transaction committed automatically.
- Parameters:
work
- a function which accepts the stateless session and returns the result of the work as aUni
.- See Also:
withStatelessSession(Function)
,Mutiny.StatelessSession.withTransaction(Function)
-
withStatelessSession
<T> io.smallrye.mutiny.Uni<T> withStatelessSession(Function<Mutiny.StatelessSession,io.smallrye.mutiny.Uni<T>> work)
Perform work using astateless session
.- If there is already a stateless session associated with the current reactive stream, then the work will be executed using that session.
- Otherwise, if there is no stateless session associated with the current stream, a new stateless session will be created.
The session will be closed automatically.
- Parameters:
work
- a function which accepts the session and returns the result of the work as aUni
.
-
withStatelessSession
<T> io.smallrye.mutiny.Uni<T> withStatelessSession(String tenantId, Function<Mutiny.StatelessSession,io.smallrye.mutiny.Uni<T>> work)
Perform work using astateless session
.- If there is already a stateless session associated with the current reactive stream and given tenant id, then the work will be executed using that session.
- Otherwise, if there is no stateless session associated with the current stream and given tenant id, a new stateless session will be created.
The session will be closed automatically.
- Parameters:
tenantId
- the id of the tenantwork
- a function which accepts the session and returns the result of the work as aUni
.
-
withTransaction
<T> io.smallrye.mutiny.Uni<T> withTransaction(String tenantId, BiFunction<Mutiny.Session,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
for a specified tenant within an associatedtransaction
.- If there is already a session associated with the current reactive stream and given tenant id, then the work will be executed using that session.
- Otherwise, if there is no session associated with the current stream and given tenant id, a new stateless session will be created.
The session will be
flushed
and closed automatically, and the transaction committed automatically.- Parameters:
tenantId
- the id of the tenantwork
- a function which accepts the session and returns the result of the work as aUni
.- See Also:
withSession(String, Function)
,Mutiny.Session.withTransaction(Function)
-
withStatelessTransaction
<T> io.smallrye.mutiny.Uni<T> withStatelessTransaction(String tenantId, BiFunction<Mutiny.StatelessSession,Mutiny.Transaction,io.smallrye.mutiny.Uni<T>> work)
Perform work using areactive session
for a specified tenant within an associatedtransaction
.- If there is already a stateless session associated with the current reactive stream and given tenant id, then the work will be executed using that session.
- Otherwise, if there is no stateless session associated with the current stream and given tenant id, a new stateless session will be created.
The session will be closed automatically and the transaction committed automatically.
- Parameters:
tenantId
- the id of the tenantwork
- a function which accepts the stateless session and returns the result of the work as aUni
.- See Also:
withStatelessSession(String, Function)
,Mutiny.StatelessSession.withTransaction(Function)
-
getCriteriaBuilder
jakarta.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
- Returns:
- an instance of
CriteriaBuilder
for creating criteria queries.
-
getMetamodel
jakarta.persistence.metamodel.Metamodel getMetamodel()
Obtain the JPAMetamodel
for the persistence unit.
-
getStatistics
Statistics getStatistics()
Obtain theStatistics
object exposing factory-level metrics.
-
close
void close()
Destroy the session factory and clean up its connection pool.- Specified by:
close
in interfaceAutoCloseable
-
isOpen
boolean isOpen()
- Returns:
- false if
close()
has been called
-
-