Package org.hibernate
Interface SharedSessionContract
-
- All Superinterfaces:
AutoCloseable
,Closeable
,QueryProducer
,Serializable
- All Known Subinterfaces:
EventSource
,Session
,SessionImplementor
,SharedSessionContractImplementor
,StatelessSession
- All Known Implementing Classes:
AbstractDelegateSessionImplementor
,AbstractSharedSessionContract
,SessionDelegatorBaseImpl
,SessionImpl
,SessionLazyDelegator
,SharedSessionDelegatorBaseImpl
,StatelessSessionImpl
,ToOneDelegateSessionImplementor
public interface SharedSessionContract extends QueryProducer, Closeable, Serializable
Declares operations that are common betweenSession
andStatelessSession
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Transaction
beginTransaction()
Begin a unit of work and return the associatedTransaction
object.void
close()
End the session by releasing the JDBC connection and cleaning up.<T> RootGraph<T>
createEntityGraph(Class<T> rootType)
Create a new mutableEntityGraph
with only a root node.<T> RootGraph<T>
createEntityGraph(Class<T> rootType, String graphName)
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.RootGraph<?>
createEntityGraph(String graphName)
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.ProcedureCall
createNamedStoredProcedureQuery(String name)
Obtain aProcedureCall
based on a named templateProcedureCall
createStoredProcedureCall(String procedureName)
Create aProcedureCall
to a stored procedure.ProcedureCall
createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureCall(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName)
Create aProcedureCall
to a stored procedure.ProcedureCall
createStoredProcedureQuery(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.void
disableFilter(String filterName)
Disable the named filter for the current session.default <T> T
doReturningWork(ReturningWork<T> work)
Perform work using theConnection
underlying by this session, and return a result.default void
doWork(Work work)
Perform work using theConnection
underlying by this session.Filter
enableFilter(String filterName)
Enable the named filter for this current session.HibernateCriteriaBuilder
getCriteriaBuilder()
Filter
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.RootGraph<?>
getEntityGraph(String graphName)
Retrieve the namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.<T> List<EntityGraph<? super T>>
getEntityGraphs(Class<T> entityClass)
Retrieve all namedEntityGraph
s with the given type.SessionFactory
getFactory()
The factory which created this session.Integer
getJdbcBatchSize()
Get the session-level JDBC batch size for the current session.ProcedureCall
getNamedProcedureCall(String name)
Obtain aProcedureCall
based on a named templateString
getTenantIdentifier()
Obtain the tenant identifier associated with this session.Object
getTenantIdentifierValue()
Obtain the tenant identifier associated with this session.Transaction
getTransaction()
Get theTransaction
instance associated with this session.boolean
isConnected()
Check if the session is currently connected.boolean
isJoinedToTransaction()
Check if the session is joined to the current transaction.boolean
isOpen()
Check if the session is still open.void
joinTransaction()
Join the currently-active JTA transaction.void
setJdbcBatchSize(Integer jdbcBatchSize)
Set the session-level JDBC batch size.-
Methods inherited from interface org.hibernate.query.QueryProducer
createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNamedSelectionQuery, createNamedSelectionQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, createQuery, createQuery, createQuery, createQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, getNamedNativeQuery, getNamedNativeQuery, getNamedQuery
-
-
-
-
Method Detail
-
getTenantIdentifier
String getTenantIdentifier()
Obtain the tenant identifier associated with this session.- Returns:
- The tenant identifier associated with this session, or
null
-
getTenantIdentifierValue
Object getTenantIdentifierValue()
Obtain the tenant identifier associated with this session.- Returns:
- The tenant identifier associated with this session, or
null
- Since:
- 6.4
-
close
void close() throws HibernateException
End the session by releasing the JDBC connection and cleaning up.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
HibernateException
- Indicates problems cleaning up.
-
isOpen
boolean isOpen()
Check if the session is still open.- Returns:
- boolean
-
isConnected
boolean isConnected()
Check if the session is currently connected.- Returns:
- boolean
-
beginTransaction
Transaction beginTransaction()
Begin a unit of work and return the associatedTransaction
object. If a new underlying transaction is required, begin the transaction. Otherwise, continue the new work in the context of the existing underlying transaction.- Returns:
- a
Transaction
instance - See Also:
getTransaction()
-
getTransaction
Transaction getTransaction()
Get theTransaction
instance associated with this session.- Returns:
- a Transaction instance
- See Also:
EntityManager.getTransaction()
-
joinTransaction
void joinTransaction()
Join the currently-active JTA transaction.- Since:
- 6.2
- See Also:
EntityManager.joinTransaction()
-
isJoinedToTransaction
boolean isJoinedToTransaction()
Check if the session is joined to the current transaction.- Since:
- 6.2
- See Also:
joinTransaction()
,EntityManager.isJoinedToTransaction()
-
getNamedProcedureCall
ProcedureCall getNamedProcedureCall(String name)
Obtain aProcedureCall
based on a named template- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureCall
ProcedureCall createStoredProcedureCall(String procedureName)
Create aProcedureCall
to a stored procedure.- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
ProcedureCall createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
createNamedStoredProcedureQuery
ProcedureCall createNamedStoredProcedureQuery(String name)
Obtain aProcedureCall
based on a named template- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureQuery
ProcedureCall createStoredProcedureQuery(String procedureName)
Create aProcedureCall
to a stored procedure.- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
ProcedureCall createStoredProcedureQuery(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
getJdbcBatchSize
Integer getJdbcBatchSize()
Get the session-level JDBC batch size for the current session.- Returns:
- the current session-level JDBC batch size
- Since:
- 5.2
- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
setJdbcBatchSize
void setJdbcBatchSize(Integer jdbcBatchSize)
Set the session-level JDBC batch size. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Parameters:
jdbcBatchSize
- the new session-level JDBC batch size- Since:
- 5.2
- See Also:
BatchSettings.STATEMENT_BATCH_SIZE
,SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
getCriteriaBuilder
HibernateCriteriaBuilder getCriteriaBuilder()
- Returns:
- an instance of
HibernateCriteriaBuilder
- Throws:
IllegalStateException
- if the session has been closed- See Also:
SessionFactory.getCriteriaBuilder()
-
doWork
default void doWork(Work work) throws HibernateException
Perform work using theConnection
underlying by this session.- Parameters:
work
- The work to be performed.- Throws:
HibernateException
- Generally indicates wrappedSQLException
-
doReturningWork
default <T> T doReturningWork(ReturningWork<T> work) throws HibernateException
Perform work using theConnection
underlying by this session, and return a result.- Type Parameters:
T
- The type of the result returned from the work- Parameters:
work
- The work to be performed.- Returns:
- the result of calling
ReturningWork.execute(java.sql.Connection)
. - Throws:
HibernateException
- Generally indicates wrappedSQLException
-
createEntityGraph
<T> RootGraph<T> createEntityGraph(Class<T> rootType)
Create a new mutableEntityGraph
with only a root node.- Parameters:
rootType
- the root entity class of the graph- Since:
- 6.3
-
createEntityGraph
RootGraph<?> createEntityGraph(String graphName)
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Parameters:
graphName
- the name of the graph- Since:
- 6.3
- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
createEntityGraph
<T> RootGraph<T> createEntityGraph(Class<T> rootType, String graphName)
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Parameters:
rootType
- the root entity class of the graphgraphName
- the name of the graph- Throws:
IllegalArgumentException
- if the graph with the given name does not have the given entity type as its root- Since:
- 6.3
- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
getEntityGraph
RootGraph<?> getEntityGraph(String graphName)
Retrieve the namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.- Parameters:
graphName
- the name of the graph- Since:
- 6.3
- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
getEntityGraphs
<T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
Retrieve all namedEntityGraph
s with the given type.- Since:
- 6.3
- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
enableFilter
Filter enableFilter(String filterName)
Enable the named filter for this current session.The returned
Filter
object must be used to bind arguments to parameters of the filter, and every parameter must be set before any other operation of this session is called.- Parameters:
filterName
- the name of the filter to be enabled.- Returns:
- the
Filter
instance representing the enabled filter. - Throws:
UnknownFilterException
- if there is no such filter- See Also:
FilterDef
-
getEnabledFilter
Filter getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.- Parameters:
filterName
- the name of the filter to be retrieved.- Returns:
- the
Filter
instance representing the enabled filter.
-
disableFilter
void disableFilter(String filterName)
Disable the named filter for the current session.- Parameters:
filterName
- the name of the filter to be disabled.
-
getFactory
SessionFactory getFactory()
The factory which created this session.
-
-