Package org.hibernate
Interface SharedSessionContract
-
- All Superinterfaces:
QueryProducer
,Serializable
- All Known Subinterfaces:
EventSource
,Session
,SessionImplementor
,SharedSessionContractImplementor
,StatelessSession
- All Known Implementing Classes:
SessionDelegatorBaseImpl
public interface SharedSessionContract extends QueryProducer, Serializable
Contract methods shared betweenSession
andStatelessSession
. NOTE : Poorly named. "shared" simply indicates that its a unified contract 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> Query<T>
createNamedQuery(String name, Class<T> resultType)
The JPA-defined named, typed query creation method.ProcedureCall
createNamedStoredProcedureQuery(String name)
Gets a ProcedureCall based on a named templateQuery
createQuery(CriteriaDelete deleteQuery)
<T> Query<T>
createQuery(CriteriaQuery<T> criteriaQuery)
Query
createQuery(CriteriaUpdate updateQuery)
Query
createQuery(String queryString)
Create aQuery
instance for the given HQL/JPQL query string.<T> Query<T>
createQuery(String queryString, Class<T> resultType)
Create a typedQuery
instance for the given HQL/JPQL query string.ProcedureCall
createStoredProcedureCall(String procedureName)
Creates a call to a stored procedure.ProcedureCall
createStoredProcedureCall(String procedureName, Class... resultClasses)
Creates a call to a stored procedure with specific result set entity mappings.ProcedureCall
createStoredProcedureCall(String procedureName, String... resultSetMappings)
Creates a call to a stored procedure with specific result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName)
Creates a call to a stored procedure.ProcedureCall
createStoredProcedureQuery(String procedureName, Class... resultClasses)
Creates a call to a stored procedure with specific result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Creates a call to a stored procedure with specific result set entity mappings.default <T> T
doReturningWork(ReturningWork<T> work)
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.default void
doWork(Work work)
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.HibernateCriteriaBuilder
getCriteriaBuilder()
Return an instance ofCriteriaBuilder
Integer
getJdbcBatchSize()
Get the Session-level JDBC batch size for the current Session.ProcedureCall
getNamedProcedureCall(String name)
Gets a ProcedureCall based on a named templateQuery
getNamedQuery(String queryName)
Create aQuery
instance for the named query.String
getTenantIdentifier()
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
isOpen()
Check if the session is still open.void
setJdbcBatchSize(Integer jdbcBatchSize)
Set the Session-level JDBC batch size.-
Methods inherited from interface org.hibernate.query.QueryProducer
createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, getNamedNativeQuery, getNamedNativeQuery
-
-
-
-
Method Detail
-
getTenantIdentifier
String getTenantIdentifier()
Obtain the tenant identifier associated with this session.- Returns:
- The tenant identifier associated with this session, or
null
-
close
void close() throws HibernateException
End the session by releasing the JDBC connection and cleaning up.- 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. The concrete type of the returnedTransaction
object is determined by thehibernate.transaction_factory
property.- Returns:
- a Transaction instance
-
createQuery
Query createQuery(String queryString)
Description copied from interface:QueryProducer
Create aQuery
instance for the given HQL/JPQL query string.- Specified by:
createQuery
in interfaceQueryProducer
- Parameters:
queryString
- The HQL/JPQL query- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String)
-
getNamedQuery
Query getNamedQuery(String queryName)
Description copied from interface:QueryProducer
Create aQuery
instance for the named query.- Specified by:
getNamedQuery
in interfaceQueryProducer
- Parameters:
queryName
- the name of a pre-defined, named query- Returns:
- The Query instance for manipulation and execution
-
getNamedProcedureCall
ProcedureCall getNamedProcedureCall(String name)
Gets a ProcedureCall based on a named template- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureCall
ProcedureCall createStoredProcedureCall(String procedureName)
Creates a call 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)
Creates a call to a stored procedure with specific result set entity mappings. Each class named 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)
Creates a call to a stored procedure with specific 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)
Gets a ProcedureCall based on a named template- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureQuery
ProcedureCall createStoredProcedureQuery(String procedureName)
Creates a call 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)
Creates a call to a stored procedure with specific result set entity mappings. Each class named 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)
Creates a call to a stored procedure with specific 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. Overrides the SessionFactory JDBC batch size defined by thehibernate.default_batch_fetch_size
configuration property for the scope of the currentSession
.- Returns:
- 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. Overrides the SessionFactory JDBC batch size defined by thehibernate.default_batch_fetch_size
configuration property for the scope of the currentSession
.- Parameters:
jdbcBatchSize
- Session-level JDBC batch size- Since:
- 5.2
- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
getCriteriaBuilder
HibernateCriteriaBuilder getCriteriaBuilder()
Return an instance ofCriteriaBuilder
- Returns:
- an instance of CriteriaBuilder
- Throws:
IllegalStateException
- if the StatelessSession has been closed
-
createQuery
<T> Query<T> createQuery(String queryString, Class<T> resultType)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given HQL/JPQL query string.- Specified by:
createQuery
in interfaceQueryProducer
- Parameters:
queryString
- The HQL/JPQL queryresultType
- The type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String,Class)
-
createQuery
<T> Query<T> createQuery(CriteriaQuery<T> criteriaQuery)
- Specified by:
createQuery
in interfaceQueryProducer
-
createQuery
Query createQuery(CriteriaUpdate updateQuery)
- Specified by:
createQuery
in interfaceQueryProducer
-
createQuery
Query createQuery(CriteriaDelete deleteQuery)
- Specified by:
createQuery
in interfaceQueryProducer
-
createNamedQuery
<T> Query<T> createNamedQuery(String name, Class<T> resultType)
Description copied from interface:QueryProducer
The JPA-defined named, typed query creation method. This form can only represent an HQL/JPQL query (not a native query).- Specified by:
createNamedQuery
in interfaceQueryProducer
- Parameters:
name
- the name of a query defined in metadataresultType
- the type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createNamedQuery(String,Class)
-
doWork
default void doWork(Work work) throws HibernateException
Controller for allowing users to perform JDBC related work using the Connection managed 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
Controller for allowing users to perform JDBC related work using the Connection managed by this Session. After execution returns the result of theReturningWork.execute(java.sql.Connection)
call.- Type Parameters:
T
- The type of the result returned from the work- Parameters:
work
- The work to be performed.- Returns:
- the result from calling
ReturningWork.execute(java.sql.Connection)
. - Throws:
HibernateException
- Generally indicates wrappedSQLException
-
-