Class SharedSessionDelegatorBaseImpl
- java.lang.Object
-
- org.hibernate.engine.spi.SharedSessionDelegatorBaseImpl
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,LobCreationContext
,SharedSessionContractImplementor
,QueryProducer
,QueryProducerImplementor
,JdbcSessionOwner
,TransactionCoordinatorBuilder.Options
,SharedSessionContract
,JavaType.CoercionContext
,WrapperOptions
public class SharedSessionDelegatorBaseImpl extends Object implements SharedSessionContractImplementor
A wrapper class that delegates all method invocations to a delegate instance ofSharedSessionContractImplementor
. This is useful for custom implementations of that API, so that only some methods need to be overridden- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.Callback<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected SharedSessionContractImplementor
delegate
-
Constructor Summary
Constructors Constructor Description SharedSessionDelegatorBaseImpl(SessionImplementor delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Transaction
accessTransaction()
Retrieves the currentTransaction
, or creates a new transaction if there is no transaction active.void
afterOperation(boolean success)
Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.void
afterScrollOperation()
Called after each operation on aScrollableResults
, providing an opportunity for a stateless session to clear its temporary persistence context.void
afterTransactionBegin()
A after-begin callback from the coordinator to its owner.void
afterTransactionCompletion(boolean successful, boolean delayed)
An after-completion callback to the owner.boolean
autoFlushIfRequired(Set<String> querySpaces)
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushboolean
autoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush)
void
autoPreFlush()
void
beforeTransactionCompletion()
A before-completion callback to the owner.Transaction
beginTransaction()
Begin a unit of work and return the associatedTransaction
object.String
bestGuessEntityName(Object object)
Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.void
checkOpen(boolean markForRollbackIfClosed)
Check whether the session is open, and if not: ifmarkForRollbackIfClosed = true
, mark the current transaction, if any, for rollback only, and throw anIllegalStateException
.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.MutationQuery
createMutationQuery(CriteriaDelete deleteQuery)
Create aMutationQuery
from the given delete criteria treeMutationQuery
createMutationQuery(CriteriaUpdate updateQuery)
Create aMutationQuery
from the given update criteria treeMutationQuery
createMutationQuery(String statementString)
Create aMutationQuery
reference for the given HQL insert, update, or delete statement.MutationQuery
createMutationQuery(JpaCriteriaInsert insertSelect)
Create aMutationQuery
from the given insert criteria treeMutationQuery
createMutationQuery(JpaCriteriaInsertSelect insertSelect)
Create aMutationQuery
from the given insert-select criteria treeMutationQuery
createNamedMutationQuery(String name)
Create aMutationQuery
instance for the given named insert, update, or delete HQL query.QueryImplementor
createNamedQuery(String name)
Create a typedQuery
instance for the given named query.<T> QueryImplementor<T>
createNamedQuery(String name, Class<T> resultClass)
Create a typedQuery
instance for the given named query.SelectionQuery<?>
createNamedSelectionQuery(String name)
Create aSelectionQuery
instance for the namedNamedQuery
.<R> SelectionQuery<R>
createNamedSelectionQuery(String name, Class<R> resultType)
Create aSelectionQuery
instance for the namedNamedQuery
with the given result type.ProcedureCall
createNamedStoredProcedureQuery(String name)
Obtain aProcedureCall
based on a named templateMutationQuery
createNativeMutationQuery(String sqlString)
Create aNativeQuery
instance for the given native SQL statement.NativeQueryImplementor
createNativeQuery(String sqlString)
Create aNativeQuery
instance for the given native SQL query.NativeQueryImplementor
createNativeQuery(String sqlString, Class resultClass)
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java type.<T> NativeQueryImplementor<T>
createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias)
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java entity type.NativeQueryImplementor
createNativeQuery(String sqlString, String resultSetMappingName)
Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.<T> NativeQueryImplementor<T>
createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass)
Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.QueryImplementor
createQuery(CriteriaDelete deleteQuery)
Create aMutationQuery
for the given JPACriteriaDelete
<T> QueryImplementor<T>
createQuery(CriteriaQuery<T> criteriaQuery)
Create aQuery
for the given JPACriteriaQuery
.QueryImplementor
createQuery(CriteriaUpdate updateQuery)
Create aMutationQuery
for the given JPACriteriaUpdate
QueryImplementor
createQuery(String queryString)
Create aQuery
instance for the given HQL query, or HQL insert, update, or delete statement.<T> QueryImplementor<T>
createQuery(String queryString, Class<T> resultType)
Create a typedQuery
instance for the given HQL query string and given query result type.<R> SelectionQuery<R>
createSelectionQuery(CriteriaQuery<R> criteria)
Create aSelectionQuery
reference for the givenCriteriaQuery
.SelectionQuery<?>
createSelectionQuery(String hqlString)
Create aSelectionQuery
reference for the given HQLselect
statement.<R> SelectionQuery<R>
createSelectionQuery(String hqlString, Class<R> resultType)
Create aSelectionQuery
instance for the given HQL query string and given query result type.ProcedureCall
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.protected SharedSessionContract
delegate()
Returns the delegate session.void
disableFilter(String filterName)
Disable the named filter for the current session.<T> T
doReturningWork(ReturningWork<T> work)
Perform work using theConnection
underlying by this session, and return a result.void
doWork(Work work)
Perform work using theConnection
underlying by this session.Filter
enableFilter(String filterName)
Enable the named filter for this current session.<T> T
execute(LobCreationContext.Callback<T> callback)
Execute the given callback, making sure it has access to a viable JDBCConnection
.void
flush()
Flush this session.void
flushBeforeTransactionCompletion()
EntityKey
generateEntityKey(Object id, EntityPersister persister)
Instantiate anEntityKey
with the given id and for the entity represented by the givenEntityPersister
.CacheMode
getCacheMode()
Get the currentCacheMode
for this session.CacheTransactionSynchronization
getCacheTransactionSynchronization()
The currentCacheTransactionSynchronization
associated with this session.Object
getContextEntityIdentifier(Object object)
Return the identifier of the persistent object, or null if it is not associated with this 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.EntityPersister
getEntityPersister(@Nullable String entityName, Object object)
Get theEntityPersister
for the given entity instance.Object
getEntityUsingInterceptor(EntityKey key)
Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.SessionEventListenerManager
getEventListenerManager()
Get theSessionEventListenerManager
associated with this session.EventManager
getEventManager()
ExceptionConverter
getExceptionConverter()
Obtain anExceptionConverter
for reporting an error.SessionFactoryImplementor
getFactory()
Obtain the factory which created this session.FlushModeType
getFlushMode()
Get the currentFlushModeType
for this session.FlushMode
getHibernateFlushMode()
Get the currentFlushMode
for this session.Interceptor
getInterceptor()
Retrieves theInterceptor
associated with this session.Integer
getJdbcBatchSize()
Get the session-level JDBC batch size for the current session.JdbcConnectionAccess
getJdbcConnectionAccess()
JdbcCoordinator
getJdbcCoordinator()
Obtain theJdbcCoordinator
for this session.JdbcServices
getJdbcServices()
Obtain theJdbcServices
for the factory which created this session.JdbcSessionContext
getJdbcSessionContext()
TimeZone
getJdbcTimeZone()
The JDBCTimeZone
used when writing a value of typeTime
orTimestamp
to a JDBCPreparedStatement
, or when reading from a JDBCResultSet
.LoadQueryInfluencers
getLoadQueryInfluencers()
Get theLoadQueryInfluencers
associated with this session.LobCreator
getLobCreator()
Obtain access to theLobCreator
.NativeQueryImplementor
getNamedNativeQuery(String name)
Get aNativeQuery
instance for a named native SQL queryNativeQueryImplementor
getNamedNativeQuery(String name, String resultSetMapping)
Get aNativeQuery
instance for a named native SQL queryProcedureCall
getNamedProcedureCall(String name)
Obtain aProcedureCall
based on a named templateQueryImplementor
getNamedQuery(String name)
Create aQuery
instance for the named query.boolean
getNativeJdbcParametersIgnored()
PersistenceContext
getPersistenceContext()
Get the persistence context for this session.PersistenceContext
getPersistenceContextInternal()
Similar toSharedSessionContractImplementor.getPersistenceContext()
, with two differences: this version performs better as it allows for inlining and probably better prediction, and it skips some checks of the current state of the session.int
getPreferredSqlTypeCodeForBoolean()
The JDBCtype code
used to bind a null boolean value.UUID
getSessionIdentifier()
Obtain aUUID
which uniquely identifies this session.String
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.TransactionCoordinator
getTransactionCoordinator()
Obtain the builder for TransactionCoordinator instancesString
guessEntityName(Object entity)
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.Object
immediateLoad(String entityName, Object id)
Load an instance immediately.void
initializeCollection(PersistentCollection<?> collection, boolean writing)
Initialize the given collection (if not already initialized).Object
instantiate(String entityName, Object id)
Instantiate the entity class, initializing with the given identifier.Object
instantiate(EntityPersister persister, Object id)
Instantiate the entity class of the givenEntityPersister
, initializing the new instance with the given identifier.Object
internalLoad(String entityName, Object id, boolean eager, boolean nullable)
Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.boolean
isAutoCloseSessionEnabled()
Is auto-close at transaction completion enabled?boolean
isClosed()
Determines whether the session is closed.boolean
isConnected()
Check if the session is currently connected.boolean
isCriteriaCopyTreeEnabled()
boolean
isDefaultReadOnly()
Are entities and proxies loaded by this session read-only by default?boolean
isJoinedToTransaction()
Check if the session is joined to the current transaction.boolean
isOpen()
Check if the session is still open.boolean
isTransactionInProgress()
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?void
joinTransaction()
Join the currently-active JTA transaction.void
markForRollbackOnly()
Marks current transaction, if any, for rollback only.void
prepareForQueryExecution(boolean requiresTxn)
Prepare for the execution of aQuery
orProcedureCall
void
setAutoClear(boolean enabled)
Enable or disable automatic cache clearing from after transaction completion.void
setCacheMode(CacheMode cm)
Set the currentCacheMode
for this session.void
setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
void
setHibernateFlushMode(FlushMode flushMode)
Set the currentFlushMode
for this session.void
setJdbcBatchSize(Integer jdbcBatchSize)
Set the session-level JDBC batch size.void
setNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored)
boolean
shouldAutoClose()
Should this session be automatically closed after the current transaction completes?boolean
shouldAutoJoinTransaction()
Indicates whether an active transaction should be automatically joined.void
startTransactionBoundary()
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transactionboolean
useStreamForLobBinding()
Determines whether streams should be used for binding LOB values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getSqlExceptionHelper
-
Methods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
fromContext
-
Methods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
asEventSource, asSessionImplementor, asStatelessSession, bestGuessEntityName, checkOpen, checkTransactionNeededForUpdateOperation, getConfiguredJdbcBatchSize, getSession, getSessionFactory, getSessionToken, getTypeConfiguration, isEnforcingFetchGraph, isEventSource, isOpenOrWaitingForAutoClose, isSessionImplementor, isStatelessSession, setEnforcingFetchGraph
-
Methods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect
-
-
-
-
Field Detail
-
delegate
protected final SharedSessionContractImplementor delegate
-
-
Constructor Detail
-
SharedSessionDelegatorBaseImpl
public SharedSessionDelegatorBaseImpl(SessionImplementor delegate)
-
-
Method Detail
-
delegate
protected SharedSessionContract delegate()
Returns the delegate session.
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContract
Obtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
- Returns:
- The tenant identifier associated with this session, or
null
-
getTenantIdentifierValue
public Object getTenantIdentifierValue()
Description copied from interface:SharedSessionContract
Obtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierValue
in interfaceSharedSessionContract
- Returns:
- The tenant identifier associated with this session, or
null
-
createMutationQuery
public MutationQuery createMutationQuery(CriteriaUpdate updateQuery)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given update criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(CriteriaDelete deleteQuery)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given delete criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given insert-select criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
-
createMutationQuery
public MutationQuery createMutationQuery(JpaCriteriaInsert insertSelect)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given insert criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
-
createQuery
public <T> QueryImplementor<T> createQuery(CriteriaQuery<T> criteriaQuery)
Description copied from interface:QueryProducer
Create aQuery
for the given JPACriteriaQuery
.- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
createQuery
public QueryImplementor createQuery(CriteriaUpdate updateQuery)
Description copied from interface:QueryProducer
Create aMutationQuery
for the given JPACriteriaUpdate
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
createQuery
public QueryImplementor createQuery(CriteriaDelete deleteQuery)
Description copied from interface:QueryProducer
Create aMutationQuery
for the given JPACriteriaDelete
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
getNamedQuery
public QueryImplementor getNamedQuery(String name)
Description copied from interface:QueryProducer
Create aQuery
instance for the named query.- Specified by:
getNamedQuery
in interfaceQueryProducer
- Specified by:
getNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- the name of a predefined named query- Returns:
- The
Query
instance for manipulation and execution
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String name)
Description copied from interface:QueryProducer
Get aNativeQuery
instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Specified by:
getNamedNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- The name of the predefined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String name, String resultSetMapping)
Description copied from interface:QueryProducer
Get aNativeQuery
instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Specified by:
getNamedNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- The name of the predefined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
createQuery
public QueryImplementor createQuery(String queryString)
Description copied from interface:QueryProducer
Create aQuery
instance for the given HQL query, or HQL insert, update, or delete statement.If a query has no explicit
select
list, the select list is inferred:- if there is exactly one root entity in the
from
clause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
from
clause, then the select list contains every root entity and every non-fetch
joined entity.
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Parameters:
queryString
- The HQL query- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createQuery(String)
- if there is exactly one root entity in the
-
createSelectionQuery
public SelectionQuery<?> createSelectionQuery(String hqlString)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the given HQLselect
statement.If the statement has no explicit
select
list, the select list is inferred:- if there is exactly one root entity in the
from
clause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
from
clause, then the select list contains every root entity and every non-fetch
joined entity.
- Specified by:
createSelectionQuery
in interfaceQueryProducer
- if there is exactly one root entity in the
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> resultType)
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the given HQL query string and given query result type.- If the query has a single item in the
select
list, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[]
,List
,Map
, orTuple
.
If a query has no explicit
select
list, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
from
clause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetch
joined entity, and each query result will be packaged into an instance of the result type, just as specified above.
The returned
Query
may be executed by callingQuery.getResultList()
orQuery.getSingleResult()
.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- Parameters:
hqlString
- The HQL query as a stringresultType
- TheClass
object representing the query result type- See Also:
EntityManager.createQuery(String)
- If the query has a single item in the
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(CriteriaQuery<R> criteria)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the givenCriteriaQuery
.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- See Also:
EntityManager.createQuery(CriteriaQuery)
-
createQuery
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> resultType)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given HQL query string and given query result type.- If the query has a single item in the
select
list, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[]
,List
,Map
, orTuple
.
If a query has no explicit
select
list, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
from
clause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetch
joined entity, and each query result will be packaged into an instance of the result type, just as specified above.
The returned
Query
may be executed by callingQuery.getResultList()
orQuery.getSingleResult()
.- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Parameters:
queryString
- The HQL queryresultType
- The type of the query result- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createQuery(String,Class)
- If the query has a single item in the
-
createNamedQuery
public QueryImplementor createNamedQuery(String name)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- the name of a predefined named query- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String)
-
createNamedQuery
public <T> QueryImplementor<T> createNamedQuery(String name, Class<T> resultClass)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- the name of a query defined in metadataresultClass
- the type of the query result- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String,Class)
-
createNamedSelectionQuery
public SelectionQuery<?> createNamedSelectionQuery(String name)
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the namedNamedQuery
.- Specified by:
createNamedSelectionQuery
in interfaceQueryProducer
-
createNamedSelectionQuery
public <R> SelectionQuery<R> createNamedSelectionQuery(String name, Class<R> resultType)
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the namedNamedQuery
with the given result type.- Specified by:
createNamedSelectionQuery
in interfaceQueryProducer
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- a native SQL query string- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String)
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java type.- If the given class is an entity class, this method is equivalent
to
createNativeQuery(sqlString).addEntity(resultClass)
. - If the given class has a registered
JavaType
, then the query must return a result set with a single column whoseJdbcType
is compatible with thatJavaType
. - Otherwise, the select items will be packaged into an instance of
the result type. The result type must have an appropriate
constructor with parameter types matching the select items, or it
must be one of the types
Object[]
,List
,Map
, orTuple
.
- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultClass
- The Java type to map results to- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
- If the given class is an entity class, this method is equivalent
to
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java entity type.The given class must be an entity class. This method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass)
.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- Native (SQL) query stringresultClass
- The Java entity class to map results totableAlias
- The table alias for columns in the result set- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMapping
annotation.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultSetMappingName
- The explicit result mapping name- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
,SqlResultSetMapping
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMapping
annotation.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultSetMappingName
- The explicit result mapping name- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
,SqlResultSetMapping
-
createMutationQuery
public MutationQuery createMutationQuery(String statementString)
Description copied from interface:QueryProducer
Create aMutationQuery
reference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createNamedMutationQuery
public MutationQuery createNamedMutationQuery(String name)
Description copied from interface:QueryProducer
Create aMutationQuery
instance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQuery
in interfaceQueryProducer
- Specified by:
createNamedMutationQuery
in interfaceQueryProducerImplementor
-
createNativeMutationQuery
public MutationQuery createNativeMutationQuery(String sqlString)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL statement.- Specified by:
createNativeMutationQuery
in interfaceQueryProducer
- Specified by:
createNativeMutationQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedStoredProcedureQuery
public ProcedureCall createNamedStoredProcedureQuery(String name)
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
createNamedStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName, Class<?>... resultClasses)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- 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
public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- 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.
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(String name)
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
getNamedProcedureCall
in interfaceSharedSessionContract
- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- 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
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- 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.
-
doWork
public void doWork(Work work) throws HibernateException
Description copied from interface:SharedSessionContract
Perform work using theConnection
underlying by this session.- Specified by:
doWork
in interfaceSharedSessionContract
- Parameters:
work
- The work to be performed.- Throws:
HibernateException
- Generally indicates wrappedSQLException
-
doReturningWork
public <T> T doReturningWork(ReturningWork<T> work) throws HibernateException
Description copied from interface:SharedSessionContract
Perform work using theConnection
underlying by this session, and return a result.- Specified by:
doReturningWork
in interfaceSharedSessionContract
- 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
-
close
public void close() throws HibernateException
Description copied from interface:SharedSessionContract
End the session by releasing the JDBC connection and cleaning up.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSharedSessionContract
- Throws:
HibernateException
- Indicates problems cleaning up.
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContract
Check if the session is still open.- Specified by:
isOpen
in interfaceSharedSessionContract
- Returns:
- boolean
-
isConnected
public boolean isConnected()
Description copied from interface:SharedSessionContract
Check if the session is currently connected.- Specified by:
isConnected
in interfaceSharedSessionContract
- Returns:
- boolean
-
beginTransaction
public Transaction beginTransaction()
Description copied from interface:SharedSessionContract
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.- Specified by:
beginTransaction
in interfaceSharedSessionContract
- Returns:
- a
Transaction
instance - See Also:
SharedSessionContract.getTransaction()
-
getTransaction
public Transaction getTransaction()
Description copied from interface:SharedSessionContract
Get theTransaction
instance associated with this session.- Specified by:
getTransaction
in interfaceSharedSessionContract
- Returns:
- a Transaction instance
- See Also:
EntityManager.getTransaction()
-
joinTransaction
public void joinTransaction()
Description copied from interface:SharedSessionContract
Join the currently-active JTA transaction.- Specified by:
joinTransaction
in interfaceSharedSessionContract
- See Also:
EntityManager.joinTransaction()
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
Description copied from interface:SharedSessionContract
Check if the session is joined to the current transaction.- Specified by:
isJoinedToTransaction
in interfaceSharedSessionContract
- See Also:
SharedSessionContract.joinTransaction()
,EntityManager.isJoinedToTransaction()
-
getCriteriaBuilder
public HibernateCriteriaBuilder getCriteriaBuilder()
Description copied from interface:SharedSessionContract
- Specified by:
getCriteriaBuilder
in interfaceSharedSessionContract
- Returns:
- an instance of
HibernateCriteriaBuilder
- See Also:
SessionFactory.getCriteriaBuilder()
-
getJdbcBatchSize
public Integer getJdbcBatchSize()
Description copied from interface:SharedSessionContract
Get the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSize
in interfaceJdbcSessionOwner
- Specified by:
getJdbcBatchSize
in interfaceSharedSessionContract
- Returns:
- the current session-level JDBC batch size
- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
getEventManager
public EventManager getEventManager()
- Specified by:
getEventManager
in interfaceJdbcSessionOwner
-
setJdbcBatchSize
public void setJdbcBatchSize(Integer jdbcBatchSize)
Description copied from interface:SharedSessionContract
Set the session-level JDBC batch size. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
- Parameters:
jdbcBatchSize
- the new session-level JDBC batch size- See Also:
BatchSettings.STATEMENT_BATCH_SIZE
,SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
execute
public <T> T execute(LobCreationContext.Callback<T> callback)
Description copied from interface:LobCreationContext
Execute the given callback, making sure it has access to a viable JDBCConnection
.- Specified by:
execute
in interfaceLobCreationContext
- Type Parameters:
T
- The Java type of the type of LOB being created. One ofBlob
,Clob
,NClob
- Parameters:
callback
- The callback to execute .- Returns:
- The LOB created by the callback.
-
getFactory
public SessionFactoryImplementor getFactory()
Description copied from interface:SharedSessionContractImplementor
Obtain the factory which created this session.- Specified by:
getFactory
in interfaceQueryProducerImplementor
- Specified by:
getFactory
in interfaceSharedSessionContract
- Specified by:
getFactory
in interfaceSharedSessionContractImplementor
-
getEventListenerManager
public SessionEventListenerManager getEventListenerManager()
Description copied from interface:SharedSessionContractImplementor
Get theSessionEventListenerManager
associated with this session.- Specified by:
getEventListenerManager
in interfaceSharedSessionContractImplementor
-
getPersistenceContext
public PersistenceContext getPersistenceContext()
Description copied from interface:SharedSessionContractImplementor
Get the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()
for a faster alternative.- Specified by:
getPersistenceContext
in interfaceSharedSessionContractImplementor
-
getJdbcCoordinator
public JdbcCoordinator getJdbcCoordinator()
Description copied from interface:SharedSessionContractImplementor
Obtain theJdbcCoordinator
for this session.- Specified by:
getJdbcCoordinator
in interfaceSharedSessionContractImplementor
-
getJdbcServices
public JdbcServices getJdbcServices()
Description copied from interface:SharedSessionContractImplementor
Obtain theJdbcServices
for the factory which created this session.- Specified by:
getJdbcServices
in interfaceSharedSessionContractImplementor
-
getSessionIdentifier
public UUID getSessionIdentifier()
Description copied from interface:SharedSessionContractImplementor
Obtain aUUID
which uniquely identifies this session.The UUID is useful mainly for logging.
- Specified by:
getSessionIdentifier
in interfaceSharedSessionContractImplementor
-
isClosed
public boolean isClosed()
Description copied from interface:SharedSessionContractImplementor
Determines whether the session is closed.- Specified by:
isClosed
in interfaceSharedSessionContractImplementor
- Returns:
true
if the session is closed;false
otherwise.
-
checkOpen
public void checkOpen(boolean markForRollbackIfClosed)
Description copied from interface:SharedSessionContractImplementor
Check whether the session is open, and if not:- if
markForRollbackIfClosed = true
, mark the current transaction, if any, for rollback only, and - throw an
IllegalStateException
. (JPA specifies this exception type.)
- Specified by:
checkOpen
in interfaceSharedSessionContractImplementor
- if
-
prepareForQueryExecution
public void prepareForQueryExecution(boolean requiresTxn)
Description copied from interface:SharedSessionContractImplementor
Prepare for the execution of aQuery
orProcedureCall
- Specified by:
prepareForQueryExecution
in interfaceSharedSessionContractImplementor
-
markForRollbackOnly
public void markForRollbackOnly()
Description copied from interface:SharedSessionContractImplementor
Marks current transaction, if any, for rollback only.- Specified by:
markForRollbackOnly
in interfaceSharedSessionContractImplementor
-
getCacheTransactionSynchronization
public CacheTransactionSynchronization getCacheTransactionSynchronization()
Description copied from interface:SharedSessionContractImplementor
The currentCacheTransactionSynchronization
associated with this session. This may benull
if the session is not currently associated with an active transaction.- Specified by:
getCacheTransactionSynchronization
in interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()
Description copied from interface:SharedSessionContractImplementor
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgress
in interfaceSharedSessionContractImplementor
-
accessTransaction
public Transaction accessTransaction()
Description copied from interface:SharedSessionContractImplementor
Retrieves the currentTransaction
, or creates a new transaction if there is no transaction active.This method is primarily for internal or integrator use.
- Specified by:
accessTransaction
in interfaceSharedSessionContractImplementor
- Returns:
- the
Transaction
-
generateEntityKey
public EntityKey generateEntityKey(Object id, EntityPersister persister)
Description copied from interface:SharedSessionContractImplementor
Instantiate anEntityKey
with the given id and for the entity represented by the givenEntityPersister
.- Specified by:
generateEntityKey
in interfaceSharedSessionContractImplementor
- Parameters:
id
- The entity idpersister
- The entity persister- Returns:
- The entity key
-
getInterceptor
public Interceptor getInterceptor()
Description copied from interface:SharedSessionContractImplementor
Retrieves theInterceptor
associated with this session.- Specified by:
getInterceptor
in interfaceSharedSessionContractImplementor
-
setAutoClear
public void setAutoClear(boolean enabled)
Description copied from interface:SharedSessionContractImplementor
Enable or disable automatic cache clearing from after transaction completion.- Specified by:
setAutoClear
in interfaceSharedSessionContractImplementor
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Initialize the given collection (if not already initialized).- Specified by:
initializeCollection
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.- When
nullable = false
, this method may create a new proxy or return an existing proxy; if it does not exist, an exception is thrown. - When
nullable = true
, the method does not create new proxies, though it might return an existing proxy; if it does not exist, anull
value is returned.
When
eager = true
, the object is eagerly fetched from the database.- Specified by:
internalLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
- When
-
immediateLoad
public Object immediateLoad(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Load an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Specified by:
immediateLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getEntityPersister
public EntityPersister getEntityPersister(@Nullable String entityName, Object object) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Get theEntityPersister
for the given entity instance.- Specified by:
getEntityPersister
in interfaceSharedSessionContractImplementor
- Parameters:
entityName
- optional entity nameobject
- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.- Specified by:
getEntityUsingInterceptor
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getContextEntityIdentifier
public Object getContextEntityIdentifier(Object object)
Description copied from interface:SharedSessionContractImplementor
Return the identifier of the persistent object, or null if it is not associated with this session.- Specified by:
getContextEntityIdentifier
in interfaceSharedSessionContractImplementor
-
bestGuessEntityName
public String bestGuessEntityName(Object object)
Description copied from interface:SharedSessionContractImplementor
Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.- Specified by:
bestGuessEntityName
in interfaceSharedSessionContractImplementor
-
guessEntityName
public String guessEntityName(Object entity) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.- Specified by:
guessEntityName
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
instantiate
public Object instantiate(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Instantiate the entity class, initializing with the given identifier.- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
instantiate
public Object instantiate(EntityPersister persister, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Instantiate the entity class of the givenEntityPersister
, initializing the new instance with the given identifier.This is more efficient than
SharedSessionContractImplementor.instantiate(String, Object)
, but not always interchangeable, since a single persister might be responsible for multiple types.- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SharedSessionContractImplementor
Are entities and proxies loaded by this session read-only by default?- Specified by:
isDefaultReadOnly
in interfaceSharedSessionContractImplementor
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SharedSessionContractImplementor
Get the currentCacheMode
for this session.- Specified by:
getCacheMode
in interfaceQueryProducerImplementor
- Specified by:
getCacheMode
in interfaceSharedSessionContractImplementor
-
setCacheMode
public void setCacheMode(CacheMode cm)
Description copied from interface:SharedSessionContractImplementor
Set the currentCacheMode
for this session.- Specified by:
setCacheMode
in interfaceSharedSessionContractImplementor
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
- Specified by:
setCriteriaCopyTreeEnabled
in interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()
- Specified by:
isCriteriaCopyTreeEnabled
in interfaceSharedSessionContractImplementor
-
getNativeJdbcParametersIgnored
public boolean getNativeJdbcParametersIgnored()
- Specified by:
getNativeJdbcParametersIgnored
in interfaceSharedSessionContractImplementor
-
setNativeJdbcParametersIgnored
public void setNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored)
- Specified by:
setNativeJdbcParametersIgnored
in interfaceSharedSessionContractImplementor
-
getFlushMode
public FlushModeType getFlushMode()
Description copied from interface:SharedSessionContractImplementor
Get the currentFlushModeType
for this session.For users of the Hibernate native APIs, we've had to rename this method as defined by Hibernate historically because the JPA contract defines a method of the same name, but returning the JPA
FlushModeType
rather than Hibernate'sFlushMode
. For the former behavior, useSharedSessionContractImplementor.getHibernateFlushMode()
instead.- Specified by:
getFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- The
FlushModeType
in effect for this Session.
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SharedSessionContractImplementor
Set the currentFlushMode
for this session.The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.
For a logically "read-only" session, it's reasonable to set the session flush mode to
FlushMode.MANUAL
at the start of the session (in order skip some work and gain some extra performance).- Specified by:
setHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Parameters:
flushMode
- the new flush mode
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:SharedSessionContractImplementor
Get the currentFlushMode
for this session.- Specified by:
getHibernateFlushMode
in interfaceQueryProducerImplementor
- Specified by:
getHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- The flush mode
-
flush
public void flush()
Description copied from interface:SharedSessionContractImplementor
Flush this session.- Specified by:
flush
in interfaceSharedSessionContractImplementor
-
afterScrollOperation
public void afterScrollOperation()
Description copied from interface:SharedSessionContractImplementor
Called after each operation on aScrollableResults
, providing an opportunity for a stateless session to clear its temporary persistence context. For a stateful session, this method does nothing.- Specified by:
afterScrollOperation
in interfaceSharedSessionContractImplementor
-
shouldAutoClose
public boolean shouldAutoClose()
Description copied from interface:SharedSessionContractImplementor
Should this session be automatically closed after the current transaction completes?- Specified by:
shouldAutoClose
in interfaceSharedSessionContractImplementor
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()
Description copied from interface:SharedSessionContractImplementor
Is auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabled
in interfaceSharedSessionContractImplementor
- See Also:
TransactionSettings.AUTO_CLOSE_SESSION
,SessionFactoryOptions.isAutoCloseSessionEnabled()
-
getLoadQueryInfluencers
public LoadQueryInfluencers getLoadQueryInfluencers()
Description copied from interface:SharedSessionContractImplementor
Get theLoadQueryInfluencers
associated with this session.- Specified by:
getLoadQueryInfluencers
in interfaceSharedSessionContractImplementor
- Returns:
- the
LoadQueryInfluencers
associated with this session; should never be null.
-
getExceptionConverter
public ExceptionConverter getExceptionConverter()
Description copied from interface:SharedSessionContractImplementor
Obtain anExceptionConverter
for reporting an error.The converter associated to a session might be lazily initialized, so only invoke this getter when there's an actual need to use it.
- Specified by:
getExceptionConverter
in interfaceSharedSessionContractImplementor
- Returns:
- the ExceptionConverter for this Session.
-
getPersistenceContextInternal
public PersistenceContext getPersistenceContextInternal()
Description copied from interface:SharedSessionContractImplementor
Similar toSharedSessionContractImplementor.getPersistenceContext()
, with two differences:- this version performs better as it allows for inlining and probably better prediction, and
- it skips some checks of the current state of the session.
- Specified by:
getPersistenceContextInternal
in interfaceSharedSessionContractImplementor
- Returns:
- the
PersistenceContext
associated to this session.
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequired
in interfaceSharedSessionContractImplementor
- Parameters:
querySpaces
- the tables named in the query.- Returns:
- true if flush is required, false otherwise.
- Throws:
HibernateException
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush) throws HibernateException
- Specified by:
autoFlushIfRequired
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
autoPreFlush
public void autoPreFlush()
- Specified by:
autoPreFlush
in interfaceSharedSessionContractImplementor
-
afterOperation
public void afterOperation(boolean success)
Description copied from interface:SharedSessionContractImplementor
Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.- Specified by:
afterOperation
in interfaceSharedSessionContractImplementor
- Parameters:
success
-true
if the operation a success
-
getJdbcSessionContext
public JdbcSessionContext getJdbcSessionContext()
- Specified by:
getJdbcSessionContext
in interfaceJdbcSessionOwner
-
getJdbcConnectionAccess
public JdbcConnectionAccess getJdbcConnectionAccess()
- Specified by:
getJdbcConnectionAccess
in interfaceJdbcSessionOwner
-
getTransactionCoordinator
public TransactionCoordinator getTransactionCoordinator()
Description copied from interface:JdbcSessionOwner
Obtain the builder for TransactionCoordinator instances- Specified by:
getTransactionCoordinator
in interfaceJdbcSessionOwner
- Returns:
- The TransactionCoordinatorBuilder
-
startTransactionBoundary
public void startTransactionBoundary()
Description copied from interface:JdbcSessionOwner
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction- Specified by:
startTransactionBoundary
in interfaceJdbcSessionOwner
-
afterTransactionBegin
public void afterTransactionBegin()
Description copied from interface:JdbcSessionOwner
A after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBegin
in interfaceJdbcSessionOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:JdbcSessionOwner
A before-completion callback to the owner.- Specified by:
beforeTransactionCompletion
in interfaceJdbcSessionOwner
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed)
Description copied from interface:JdbcSessionOwner
An after-completion callback to the owner.- Specified by:
afterTransactionCompletion
in interfaceJdbcSessionOwner
- Parameters:
successful
- Was the transaction successful?delayed
- Is this a delayed after transaction completion call (aka after a timeout)?
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()
- Specified by:
flushBeforeTransactionCompletion
in interfaceJdbcSessionOwner
-
shouldAutoJoinTransaction
public boolean shouldAutoJoinTransaction()
Description copied from interface:TransactionCoordinatorBuilder.Options
Indicates whether an active transaction should be automatically joined. Only relevant for JTA-based TransactionCoordinator instances.- Specified by:
shouldAutoJoinTransaction
in interfaceTransactionCoordinatorBuilder.Options
- Returns:
true
indicates the active transaction should be auto joined;false
indicates it should not (untilTransactionCoordinator.explicitJoin()
is called).
-
useStreamForLobBinding
public boolean useStreamForLobBinding()
Description copied from interface:WrapperOptions
Determines whether streams should be used for binding LOB values.- Specified by:
useStreamForLobBinding
in interfaceWrapperOptions
- Returns:
true
/false
- See Also:
Dialect.useInputStreamToInsertBlob()
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()
Description copied from interface:WrapperOptions
The JDBCtype code
used to bind a null boolean value.- Specified by:
getPreferredSqlTypeCodeForBoolean
in interfaceWrapperOptions
- See Also:
MappingSettings.PREFERRED_BOOLEAN_JDBC_TYPE
,Dialect.getPreferredSqlTypeCodeForBoolean()
-
getLobCreator
public LobCreator getLobCreator()
Description copied from interface:WrapperOptions
Obtain access to theLobCreator
.- Specified by:
getLobCreator
in interfaceWrapperOptions
- Returns:
- The LOB creator
- See Also:
JdbcSettings.NON_CONTEXTUAL_LOB_CREATION
,Dialect.getDefaultNonContextualLobCreation()
-
getJdbcTimeZone
public TimeZone getJdbcTimeZone()
Description copied from interface:WrapperOptions
The JDBCTimeZone
used when writing a value of typeTime
orTimestamp
to a JDBCPreparedStatement
, or when reading from a JDBCResultSet
.- When
getJdbcTimeZone()
is null, the methodPreparedStatement.setTimestamp(int, java.sql.Timestamp)
is called to write a timestamp, andResultSet.getTimestamp(int)
is called to read a timestamp. - But when not null, the method
PreparedStatement.setTimestamp(int, java.sql.Timestamp, java.util.Calendar)
is called to write a timestamp, andResultSet.getTimestamp(int, java.util.Calendar)
is called to read a timestamp.
Thus, the storage
TimeZone
can differ from the default JVM TimeZone given byTimeZone.getDefault()
.- Specified by:
getJdbcTimeZone
in interfaceWrapperOptions
- Returns:
- the JDBC
TimeZone
, or null if no JDBC timezone was explicitly set - See Also:
JdbcSettings.JDBC_TIME_ZONE
- When
-
createEntityGraph
public <T> RootGraph<T> createEntityGraph(Class<T> rootType)
Description copied from interface:SharedSessionContract
Create a new mutableEntityGraph
with only a root node.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
rootType
- the root entity class of the graph
-
createEntityGraph
public RootGraph<?> createEntityGraph(String graphName)
Description copied from interface:SharedSessionContract
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
graphName
- the name of the graph- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
createEntityGraph
public <T> RootGraph<T> createEntityGraph(Class<T> rootType, String graphName)
Description copied from interface:SharedSessionContract
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
rootType
- the root entity class of the graphgraphName
- the name of the graph- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
getEntityGraph
public RootGraph<?> getEntityGraph(String graphName)
Description copied from interface:SharedSessionContract
Retrieve the namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.- Specified by:
getEntityGraph
in interfaceSharedSessionContract
- Parameters:
graphName
- the name of the graph- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
getEntityGraphs
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
Description copied from interface:SharedSessionContract
Retrieve all namedEntityGraph
s with the given type.- Specified by:
getEntityGraphs
in interfaceSharedSessionContract
- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
enableFilter
public Filter enableFilter(String filterName)
Description copied from interface:SharedSessionContract
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.- Specified by:
enableFilter
in interfaceSharedSessionContract
- Parameters:
filterName
- the name of the filter to be enabled.- Returns:
- the
Filter
instance representing the enabled filter. - See Also:
FilterDef
-
getEnabledFilter
public Filter getEnabledFilter(String filterName)
Description copied from interface:SharedSessionContract
Retrieve a currently enabled filter by name.- Specified by:
getEnabledFilter
in interfaceSharedSessionContract
- Parameters:
filterName
- the name of the filter to be retrieved.- Returns:
- the
Filter
instance representing the enabled filter.
-
disableFilter
public void disableFilter(String filterName)
Description copied from interface:SharedSessionContract
Disable the named filter for the current session.- Specified by:
disableFilter
in interfaceSharedSessionContract
- Parameters:
filterName
- the name of the filter to be disabled.
-
-