Package org.hibernate
Interface SharedSessionContract
-
- All Superinterfaces:
AutoCloseable,Closeable,QueryProducer,Serializable
- All Known Subinterfaces:
EventSource,Session,SessionImplementor,SharedSessionContractImplementor,StatelessSession
- All Known Implementing Classes:
SessionDelegatorBaseImpl,SessionLazyDelegator
public interface SharedSessionContract extends QueryProducer, Closeable, Serializable
Declares operations that are common betweenSessionandStatelessSession.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TransactionbeginTransaction()Begin a unit of work and return the associatedTransactionobject.voidclose()End the session by releasing the JDBC connection and cleaning up.ProcedureCallcreateNamedStoredProcedureQuery(String name)Obtain aProcedureCallbased on a named templateProcedureCallcreateStoredProcedureCall(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureCall(String procedureName, Class<?>... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureCall(String procedureName, String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureQuery(String procedureName, Class<?>... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName, String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.default <T> TdoReturningWork(ReturningWork<T> work)Perform work using theConnectionunderlying by this session, and return a result.default voiddoWork(Work work)Perform work using theConnectionunderlying by this session.HibernateCriteriaBuildergetCriteriaBuilder()Return an instance ofCriteriaBuilder.IntegergetJdbcBatchSize()Get the session-level JDBC batch size for the current session.ProcedureCallgetNamedProcedureCall(String name)Obtain aProcedureCallbased on a named templateStringgetTenantIdentifier()Obtain the tenant identifier associated with this session.TransactiongetTransaction()Get theTransactioninstance associated with this session.booleanisConnected()Check if the session is currently connected.booleanisOpen()Check if the session is still open.voidsetJdbcBatchSize(Integer jdbcBatchSize)Set the session-level JDBC batch size.-
Methods inherited from interface org.hibernate.query.QueryProducer
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
-
close
void close() throws HibernateExceptionEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein 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 associatedTransactionobject. 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
Transactioninstance - See Also:
getTransaction()
-
getTransaction
Transaction getTransaction()
Get theTransactioninstance associated with this session.- Returns:
- a Transaction instance
-
getNamedProcedureCall
ProcedureCall getNamedProcedureCall(String name)
Obtain aProcedureCallbased on a named template- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureCall
ProcedureCall createStoredProcedureCall(String procedureName)
Create aProcedureCallto 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 aProcedureCallto 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 aProcedureCallto 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 aProcedureCallbased on a named template- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureQuery
ProcedureCall createStoredProcedureQuery(String procedureName)
Create aProcedureCallto 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 aProcedureCallto 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 aProcedureCallto 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. Overrides thefactory-levelJDBC batch size defined by the configuration property "hibernate.jdbc.batch_size".- Parameters:
jdbcBatchSize- the new 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 session has been closed
-
doWork
default void doWork(Work work) throws HibernateException
Perform work using theConnectionunderlying 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 theConnectionunderlying 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
-
-