public static interface Stage.SessionFactory extends AutoCloseable
reactive sessions
.
A Stage.SessionFactory
may be obtained from an instance of
EntityManagerFactory
as follows:
Stage.SessionFactory sessionFactory = createEntityManagerFactory("example") .unwrap(Stage.SessionFactory.class);Here, configuration properties must be specified in
persistence.xml
.
Alternatively, a Stage.SessionFactory
may be obtained via
programmatic configuration of Hibernate using:
Configuration configuration = new Configuration(); ... Stage.SessionFactory sessionFactory = configuration.buildSessionFactory( new ReactiveServiceRegistryBuilder() .applySettings( configuration.getProperties() ) .build() ) .unwrap(Stage.SessionFactory.class);
CompletionStage<Stage.Session> openSession()
reactive session
CompletionStage
, the main
interaction point between the user's program and Hibernate
Reactive.
When the CompletionStage
completes successfully it returns a newly created session.
The client must explicitly close the session by calling
Stage.Closeable.close()
.
withSession(Function)
CompletionStage<Stage.Session> openSession(String tenantId)
reactive session
CompletionStage
for a
specified tenant.
When the CompletionStage
completes successfully it returns a newly created session.
The client must explicitly close the session by calling
Stage.Closeable.close()
.
tenantId
- the id of the tenantwithSession(Function)
CompletionStage<Stage.StatelessSession> openStatelessSession()
reactive stateless session
CompletionStage
.
When the CompletionStage
completes successfully it returns a newly created session.
The client must explicitly close the session by calling
Stage.StatelessSession.close()
.
CompletionStage<Stage.StatelessSession> openStatelessSession(String tenantId)
reactive stateless session
CompletionStage
.
When the CompletionStage
completes successfully it returns a newly created session.
The client must explicitly close the session by calling
Stage.StatelessSession.close()
.
tenantId
- the id of the tenant<T> CompletionStage<T> withSession(Function<Stage.Session,CompletionStage<T>> work)
reactive session
.
The session will be closed automatically, but must be flushed explicitly if necessary.
work
- a function which accepts the session and returns
the result of the work as a CompletionStage
.<T> CompletionStage<T> withSession(String tenantId, Function<Stage.Session,CompletionStage<T>> work)
reactive session
for a
specified tenant.
The session will be closed automatically, but must be flushed explicitly if necessary.
tenantId
- the id of the tenantwork
- a function which accepts the session and returns
the result of the work as a CompletionStage
.<T> CompletionStage<T> withTransaction(BiFunction<Stage.Session,Stage.Transaction,CompletionStage<T>> work)
reactive session
within an
associated transaction
.
The session will be flushed
and closed
automatically, and the transaction committed automatically.
work
- a function which accepts the session and transaction
and returns the result of the work as a
CompletionStage
.withSession(Function)
,
Stage.Session.withTransaction(Function)
default <T> CompletionStage<T> withTransaction(Function<Stage.Session,CompletionStage<T>> work)
reactive session
within an
associated transaction.
The session will be flushed
and closed
automatically, and the transaction committed automatically.
work
- a function which accepts the session and returns the
result of the work as a CompletionStage
.withTransaction(BiFunction)
,
Stage.Session.withTransaction(Function)
<T> CompletionStage<T> withTransaction(String tenantId, BiFunction<Stage.Session,Stage.Transaction,CompletionStage<T>> work)
reactive session
for a
specified tenant within an associated transaction
.
The session will be flushed
and closed
automatically, and the transaction committed automatically.
tenantId
- the id of the tenantwork
- a function which accepts the session and returns
the result of the work as a CompletionStage
.withSession(String, Function)
,
Stage.Session.withTransaction(Function)
default <T> CompletionStage<T> withStatelessTransaction(Function<Stage.StatelessSession,CompletionStage<T>> work)
reactive session
within an
associated transaction
.
The session will be closed automatically, and the transaction committed automatically.
work
- a function which accepts the stateless session and returns
the result of the work as a CompletionStage
.withStatelessSession(Function)
,
Stage.StatelessSession.withTransaction(Function)
<T> CompletionStage<T> withStatelessTransaction(BiFunction<Stage.StatelessSession,Stage.Transaction,CompletionStage<T>> work)
reactive session
within an
associated transaction
.
The session will be closed automatically, and the transaction committed automatically.
work
- a function which accepts the stateless session and returns
the result of the work as a CompletionStage
.withStatelessSession(Function)
,
Stage.StatelessSession.withTransaction(Function)
<T> CompletionStage<T> withStatelessTransaction(String tenantId, BiFunction<Stage.StatelessSession,Stage.Transaction,CompletionStage<T>> work)
reactive session
within an
associated transaction
.
The session will be closed automatically, and the transaction committed automatically.
tenantId
- the id of the tenantwork
- a function which accepts the stateless session and returns
the result of the work as a CompletionStage
.withStatelessSession(String, Function)
,
Stage.StatelessSession.withTransaction(Function)
<T> CompletionStage<T> withStatelessSession(Function<Stage.StatelessSession,CompletionStage<T>> work)
stateless session
.
The session will be closed automatically.
work
- a function which accepts the session and returns
the result of the work as a CompletionStage
.<T> CompletionStage<T> withStatelessSession(String tenantId, Function<Stage.StatelessSession,CompletionStage<T>> work)
stateless session
.
The session will be closed automatically.
tenantId
- the id of the tenantwork
- a function which accepts the session and returns
the result of the work as a CompletionStage
.CriteriaBuilder getCriteriaBuilder()
CriteriaBuilder
for creating
criteria queries.org.hibernate.Cache getCache()
Cache
object for managing the second-level
cache.void close()
close
in interface AutoCloseable
boolean isOpen()
close()
has been calledCopyright © 2020-2022 Red Hat, Inc. All Rights Reserved.