Class StageSessionFactoryImpl
- All Implemented Interfaces:
AutoCloseable,Implementor,Stage.SessionFactory
Stage.SessionFactory.
Obtained by calling EntityManagerFactory.unwrap(Class).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Destroy the session factory and clean up its connection pool.org.hibernate.CachegetCache()Obtain theCacheobject for managing the second-level cache.org.hibernate.query.criteria.HibernateCriteriaBuilderReturn the current instance ofStage.Session, if any.Return the current instance ofStage.Session, if any.jakarta.persistence.metamodel.MetamodelObtain the JPAMetamodelfor the persistence unit.org.hibernate.service.ServiceRegistryorg.hibernate.stat.StatisticsObtain theStatisticsobject exposing factory-level metrics.getUuid()booleanisOpen()Obtain a new reactive sessionCompletionStage, the main interaction point between the user's program and Hibernate Reactive.openSession(String tenantId) Obtain a new reactive sessionCompletionStagefor a specified tenant.Obtain areactive stateless sessionCompletionStage.openStatelessSession(String tenantId) Obtain areactive stateless sessionCompletionStage.<T> CompletionStage<T>withSession(String tenantId, Function<Stage.Session, CompletionStage<T>> work) Perform work using a reactive session for a specified tenant.<T> CompletionStage<T>withSession(Function<Stage.Session, CompletionStage<T>> work) Perform work using a reactive session.<T> CompletionStage<T>withStatelessSession(String tenantId, Function<Stage.StatelessSession, CompletionStage<T>> work) Perform work using a stateless session.<T> CompletionStage<T>Perform work using a stateless session.<T> CompletionStage<T>withStatelessTransaction(String tenantId, BiFunction<Stage.StatelessSession, Stage.Transaction, CompletionStage<T>> work) Perform work using a reactive session for the tenant with the specified tenant id within an associatedtransaction.<T> CompletionStage<T>withStatelessTransaction(BiFunction<Stage.StatelessSession, Stage.Transaction, CompletionStage<T>> work) Perform work using a reactive session within an associatedtransaction.<T> CompletionStage<T>withTransaction(String tenantId, BiFunction<Stage.Session, Stage.Transaction, CompletionStage<T>> work) Perform work using a reactive session for the tenant with the specified tenant id within an associatedtransaction.<T> CompletionStage<T>Perform work using a reactive session within an associatedtransaction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.reactive.stage.Stage.SessionFactory
withStatelessTransaction, withTransaction
-
Constructor Details
-
StageSessionFactoryImpl
public StageSessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl delegate)
-
-
Method Details
-
getUuid
- Specified by:
getUuidin interfaceImplementor
-
getServiceRegistry
public org.hibernate.service.ServiceRegistry getServiceRegistry()- Specified by:
getServiceRegistryin interfaceImplementor
-
getContext
- Specified by:
getContextin interfaceImplementor
-
openSession
Description copied from interface:Stage.SessionFactoryObtain a new reactive sessionCompletionStage, the main interaction point between the user's program and Hibernate Reactive.When the
CompletionStagecompletes successfully it returns a newly created session.The client must explicitly close the session by calling
Stage.Closeable.close().- Specified by:
openSessionin interfaceStage.SessionFactory- See Also:
-
openSession
Description copied from interface:Stage.SessionFactoryObtain a new reactive sessionCompletionStagefor a specified tenant.When the
CompletionStagecompletes successfully it returns a newly created session.The client must explicitly close the session by calling
Stage.Closeable.close().- Specified by:
openSessionin interfaceStage.SessionFactory- Parameters:
tenantId- the id of the tenant- See Also:
-
openStatelessSession
Description copied from interface:Stage.SessionFactoryObtain areactive stateless sessionCompletionStage.When the
CompletionStagecompletes successfully it returns a newly created session.The client must explicitly close the session by calling
Stage.StatelessSession.close().- Specified by:
openStatelessSessionin interfaceStage.SessionFactory
-
openStatelessSession
Description copied from interface:Stage.SessionFactoryObtain areactive stateless sessionCompletionStage.When the
CompletionStagecompletes successfully it returns a newly created session.The client must explicitly close the session by calling
Stage.StatelessSession.close().- Specified by:
openStatelessSessionin interfaceStage.SessionFactory- Parameters:
tenantId- the id of the tenant
-
getCurrentSession
Description copied from interface:Stage.SessionFactoryReturn the current instance ofStage.Session, if any. A current session exists only when this method is called from within an invocation ofStage.SessionFactory.withSession(Function)orStage.SessionFactory.withTransaction(Function).- Specified by:
getCurrentSessionin interfaceStage.SessionFactory- Returns:
- the current instance, if any, or
null
-
getCurrentStatelessSession
Description copied from interface:Stage.SessionFactoryReturn the current instance ofStage.Session, if any. A current session exists only when this method is called from within an invocation ofStage.SessionFactory.withStatelessSession(Function)orStage.SessionFactory.withStatelessTransaction(Function).- Specified by:
getCurrentStatelessSessionin interfaceStage.SessionFactory- Returns:
- the current instance, if any, or
null
-
withSession
Description copied from interface:Stage.SessionFactoryPerform work using a reactive 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.
- Specified by:
withSessionin interfaceStage.SessionFactory- Parameters:
work- a function which accepts the session and returns the result of the work as aCompletionStage.
-
withSession
public <T> CompletionStage<T> withSession(String tenantId, Function<Stage.Session, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a reactive 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.
- Specified by:
withSessionin interfaceStage.SessionFactory- Parameters:
tenantId- the id of the tenantwork- a function which accepts the session and returns the result of the work as aCompletionStage.
-
withStatelessSession
public <T> CompletionStage<T> withStatelessSession(Function<Stage.StatelessSession, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a stateless 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.
- Specified by:
withStatelessSessionin interfaceStage.SessionFactory- Parameters:
work- a function which accepts the session and returns the result of the work as aCompletionStage.
-
withStatelessSession
public <T> CompletionStage<T> withStatelessSession(String tenantId, Function<Stage.StatelessSession, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a stateless 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.
- Specified by:
withStatelessSessionin interfaceStage.SessionFactory- Parameters:
tenantId- the id of the tenantwork- a function which accepts the session and returns the result of the work as aCompletionStage.
-
withTransaction
public <T> CompletionStage<T> withTransaction(BiFunction<Stage.Session, Stage.Transaction, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a reactive 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
flushedand closed automatically, and the transaction committed automatically.- Specified by:
withTransactionin interfaceStage.SessionFactory- Parameters:
work- a function which accepts the session and transaction and returns the result of the work as aCompletionStage.- See Also:
-
withStatelessTransaction
public <T> CompletionStage<T> withStatelessTransaction(BiFunction<Stage.StatelessSession, Stage.Transaction, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a reactive 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.
- Specified by:
withStatelessTransactionin interfaceStage.SessionFactory- Parameters:
work- a function which accepts the stateless session and returns the result of the work as aCompletionStage.- See Also:
-
withTransaction
public <T> CompletionStage<T> withTransaction(String tenantId, BiFunction<Stage.Session, Stage.Transaction, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a reactive session for the tenant with the specified tenant id 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 stateless session associated with the current stream and given tenant id, a new stateless session will be created.
The session will be
flushedand closed automatically, and the transaction committed automatically.- Specified by:
withTransactionin interfaceStage.SessionFactory- Parameters:
tenantId- the id of the tenantwork- a function which accepts the session and returns the result of the work as aCompletionStage.- See Also:
-
withStatelessTransaction
public <T> CompletionStage<T> withStatelessTransaction(String tenantId, BiFunction<Stage.StatelessSession, Stage.Transaction, CompletionStage<T>> work) Description copied from interface:Stage.SessionFactoryPerform work using a reactive session for the tenant with the specified tenant id 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.
- Specified by:
withStatelessTransactionin interfaceStage.SessionFactory- Parameters:
tenantId- the id of the tenantwork- a function which accepts the stateless session and returns the result of the work as aCompletionStage.- See Also:
-
getMetamodel
public jakarta.persistence.metamodel.Metamodel getMetamodel()Description copied from interface:Stage.SessionFactoryObtain the JPAMetamodelfor the persistence unit.- Specified by:
getMetamodelin interfaceStage.SessionFactory
-
getCache
public org.hibernate.Cache getCache()Description copied from interface:Stage.SessionFactoryObtain theCacheobject for managing the second-level cache.- Specified by:
getCachein interfaceStage.SessionFactory
-
getStatistics
public org.hibernate.stat.Statistics getStatistics()Description copied from interface:Stage.SessionFactoryObtain theStatisticsobject exposing factory-level metrics.- Specified by:
getStatisticsin interfaceStage.SessionFactory
-
close
public void close()Description copied from interface:Stage.SessionFactoryDestroy the session factory and clean up its connection pool.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStage.SessionFactory
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceStage.SessionFactory- Returns:
- false if
Stage.SessionFactory.close()has been called
-
getCriteriaBuilder
public org.hibernate.query.criteria.HibernateCriteriaBuilder getCriteriaBuilder()- Specified by:
getCriteriaBuilderin interfaceStage.SessionFactory- Returns:
- an instance of
CriteriaBuilderfor creating criteria queries.
-