Class SessionImpl
- All Implemented Interfaces:
EntityManager,Serializable,AutoCloseable,LobCreationContext,SessionImplementor,SharedSessionContractImplementor,EventSource,LoadAccessContext,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,Session,SharedSessionContract,JavaType.CoercionContext,WrapperOptions
Session API.
Exposes two interfaces:
Sessionto the application, andSessionImplementorandEventSource(both SPI interfaces) to other subsystems.
This class is not thread-safe.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.Callback<T>Nested classes/interfaces inherited from interface org.hibernate.Session
Session.LockRequest -
Field Summary
Fields inherited from class org.hibernate.internal.AbstractSharedSessionContract
closed, fastSessionServices, waitingForAutoClose -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListeners(SessionEventListener... listeners) Add one or more listeners to the Sessionprotected voidaddSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) voidafterOperation(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.voidCalled after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context.voidA after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed) An after-completion callback to the owner.protected voidapplyLockOptionsHint(SelectionQuery<?> query) protected voidapplyQuerySettingsAndHints(Query<?> query) protected voidapplyQuerySettingsAndHints(SelectionQuery<?> query) Cast this session toEventSourceif possible.booleanautoFlushIfRequired(Set<String> querySpaces) detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushbooleanautoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush) voidvoidA before-completion callback to the owner.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.bestGuessEntityName(Object object, EntityEntry entry) 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.buildLockRequest(LockOptions lockOptions) Deprecated.<T> IdentifierLoadAccessImpl<T>Create anIdentifierLoadAccessinstance to retrieve an instance of the given entity type by its primary key.<T> IdentifierLoadAccessImpl<T>Create anIdentifierLoadAccessinstance to retrieve an instance of the named entity type by its primary key.<T> MultiIdentifierLoadAccess<T>byMultipleIds(Class<T> entityClass) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their primary key values, using batching.<T> MultiIdentifierLoadAccess<T>byMultipleIds(String entityName) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their primary key values, using batching.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(Class<T> entityClass) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their by natural id values, using batching.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(String entityName) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their by natural id values, using batching.<T> NaturalIdLoadAccess<T>byNaturalId(Class<T> entityClass) Create aNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which may be a composite natural id.<T> NaturalIdLoadAccess<T>byNaturalId(String entityName) Create aNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which may be a composite natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(Class<T> entityClass) Create aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which must be a simple (non-composite) value.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(String entityName) Create aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which must be a simple (non-composite) value.voidCancel the execution of the current query.protected voidprotected voidvoidCallback to check whether the session is "active"protected voidprotected voidclear all the internal collections, just to help the garbage collector, does not clear anything that is needed during the afterTransactionCompletion() phasevoidclear()Completely clear the session.voidclose()End the session by releasing the JDBC connection and cleaning up.voidbooleanbooleanDetermine if the given entity is associated with this session.protected ActionQueueObtain aProcedureCallbased on a named templateprotected StatefulPersistenceContext<T> QueryImplementor<T>createQuery(CriteriaSelect<T> selectQuery) createStoredProcedureCall(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureCall(String procedureName, Class<?>... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureCall(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureQuery(String procedureName, Class... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.voidvoiddelete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) Cascade delete an entity instancevoidRemove this instance from the session cache.protected CacheModedetermineAppropriateLocalCacheMode(Map<String, Object> localProperties) voiddisableFetchProfile(String name) Disable thefetch profilewith the given name in this session.voidenableFetchProfile(String name) Enable thefetch profilewith the given name in this session.voidremove any hard references to the entity that are held by the infrastructure (references held by application or other persistent instances are okay)<T> Tfind(EntityGraph<T> entityGraph, Object primaryKey, FindOption... options) <T> T<T> Tfind(Class<T> entityClass, Object primaryKey, FindOption... options) <T> Tfind(Class<T> entityClass, Object primaryKey, LockModeType lockModeType) <T> Tfind(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) <T> TvoidfireLoad(LoadEvent event, LoadEventListener.LoadType loadType) voidflush()Flush this session.voidvoidforceFlush(EntityEntry entityEntry) Initiate a flush to force deletion of a re-persisted entity.voidforceFlush(EntityKey key) Initiate a flush to force deletion of a re-persisted entity.<T> TReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> TReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> Tget(Class<T> entityClass, Object id, LockOptions lockOptions) Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.get(String entityName, Object id, LockOptions lockOptions) Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.Get theActionQueueassociated with this session.The JPA-definedCacheRetrieveMode.The JPA-definedCacheStoreMode.getContextEntityIdentifier(Object object) Get the id value for an object that is actually associated with the session.getCurrentLockMode(Object object) Determine the currentLockModeof the given managed instance associated with this session.getEntityName(Object object) Return the entity name for a persistent entity.getEntityPersister(String entityName, Object object) Get theEntityPersisterfor the given entity instance.Get the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.intGet the maximum batch size for batch fetching associations by id in this session.getIdentifier(Object object) Return the identifier value of the given entity associated with this session.Get theLoadQueryInfluencersassociated with this session.getLockMode(Object entity) Get the persistence context for this session.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.<T> TgetReference(Class<T> entityClass, Object id) Return a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database.getReference(String entityName, Object id) Return a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database.<T> TgetReference(T object) Return a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database.Returns this object, fulfilling the contract ofWrapperOptions.Obtain the factory which created this session.Get the statistics for this session.guessEntityName(Object object) Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.immediateLoad(String entityName, Object id) Load the data for the object with the specified id into a newly created object.voidinitializeCollection(PersistentCollection<?> collection, boolean writing) Initialize the given collection (if not already initialized).instantiate(String entityName, Object id) Instantiate the entity class, initializing with the given identifier.instantiate(EntityPersister persister, Object id) give the interceptor an opportunity to override the default instantiationinternalLoad(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.protected static LoadEventListener.LoadTypeinternalLoadType(boolean eager, boolean nullable) booleanIs auto-close at transaction completion enabled?booleanAre entities and proxies loaded by this session read-only by default?booleanisDirty()Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?booleanDetermines if this session implementsEventSource.booleanisFetchProfileEnabled(String name) Is thefetch profilewith the given name enabled in this session?booleanisOpen()Check if the session is still open.booleanisReadOnly(Object entityOrProxy) Is the specified entity or proxy read-only?booleanDetermine if subselect fetching is enabled in this session.<T> TDeprecated.<T> TDeprecated.<T> Tload(Class<T> entityClass, Object id, LockOptions lockOptions) Deprecated.voidRead the persistent state associated with the given identifier into the given transient instance.Deprecated.Deprecated.load(String entityName, Object id, LockOptions lockOptions) Deprecated.voidlock(Object entity, LockModeType lockModeType) voidlock(Object entity, LockModeType lockMode, LockOption... options) voidvoidObtain the specified lock level on the given managed instance associated with this session.voidlock(Object object, LockOptions lockOptions) Obtain a lock on the given managed instance associated with this session, using the given lock options.voidObtain the specified lock level on the given managed instance associated with this session.voidlock(String entityName, Object object, LockOptions lockOptions) Cascade the lock operation to the given child entity.voidmerge(String entityName, Object object, MergeContext copiedAlready) Cascade merge an entity instance<T> TCopy the state of the given object onto the persistent object with the same identifier.<T> Tmerge(T object) Copy the state of the given object onto the persistent object with the same identifier.voidMake a transient instance persistent and mark it for later insertion in the database.voidMake a transient instance persistent and mark it for later insertion in the database.voidpersist(String entityName, Object object, PersistContext copiedAlready) Cascade persist an entity instancevoidpersistOnFlush(String entityName, Object object, PersistContext copiedAlready) Cascade persist an entity instance during the flush processvoidCallback to pulse the transaction coovoidReread the state of the given managed instance associated with this session from the underlying database.voidrefresh(Object entity, LockModeType lockModeType) voidvoidrefresh(Object entity, RefreshOption... options) voidvoidReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidrefresh(Object object, LockOptions lockOptions) Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidrefresh(String entityName, Object object, RefreshContext refreshedAlready) Cascade refresh an entity instancevoidMark a persistence instance associated with this session for removal from the underlying database.voidremoveOrphanBeforeUpdates(String entityName, Object child) A specialized type of deletion for orphan removal that must occur prior to queued inserts and updates.protected voidremoveSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) voidreplicate(Object obj, ReplicationMode replicationMode) Persist the state of the given detached instance, reusing the current identifier value.voidreplicate(String entityName, Object obj, ReplicationMode replicationMode) Persist the state of the given detached instance, reusing the current identifier value.Obtain aSessionbuilder with the ability to copy certain information from this session.voidsetAutoClear(boolean enabled) Enable or disable automatic cache clearing from after transaction completion.voidsetCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) Enable or disable reads from the second-level cache.voidsetCacheStoreMode(CacheStoreMode cacheStoreMode) Enable or disable writes to the second-level cache.voidsetDefaultReadOnly(boolean defaultReadOnly) Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.voidsetFetchBatchSize(int batchSize) Set the maximum batch size for batch fetching associations by id in this session.voidsetFlushMode(FlushModeType flushModeType) Set the currentJPA flush modefor this session.voidsetProperty(String propertyName, Object value) voidsetReadOnly(Object entity, boolean readOnly) Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.voidsetSubselectFetchingEnabled(boolean enabled) Enable or disable subselect fetching in this session.booleanShould this session be automatically closed after the current transaction completes?protected booleanshouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) voidCallback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransactionAPI or via registration of Hibernate's JTA Synchronization impl with a JTA TransactiontoString()<T> TMethods inherited from class org.hibernate.internal.AbstractSharedSessionContract
accessTransaction, addResultType, beginTransaction, buildNamedQuery, buildNamedQuery, checkMutationQuery, checkOpen, checkResultType, checkSelectionQuery, checkTransactionNeededForUpdateOperation, checkTransactionSynchStatus, createCriteriaQuery, createEntityGraph, createEntityGraph, createEntityGraph, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNamedSelectionQuery, createNamedSelectionQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQueryImplementor, createNativeQueryImplementor, createQuery, createQuery, createQuery, createQuery, createQuery, createQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, createSqmQueryImplementor, createSqmQueryImplementor, disableFilter, doReturningWork, doWork, enableFilter, execute, generateEntityKey, getCacheMode, getCacheTransactionSynchronization, getConfiguredJdbcBatchSize, getCriteriaBuilder, getCurrentTransaction, getEnabledFilter, getEntityGraph, getEntityGraphs, getEntityNameResolver, getEventListenerManager, getEventManager, getExceptionConverter, getFactory, getFlushMode, getHibernateFlushMode, getInterceptor, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcCoordinator, getJdbcServices, getJdbcSessionContext, getJdbcTimeZone, getLobCreator, getNamedNativeQuery, getNamedNativeQuery, getNamedProcedureCall, getNamedQuery, getNativeJdbcParametersIgnored, getPreferredSqlTypeCodeForBoolean, getResultSetMappingMemento, getSessionIdentifier, getSessionToken, getTenantIdentifier, getTenantIdentifierValue, getTransaction, getTransactionCoordinator, interpretHql, isClosed, isConnected, isCriteriaCopyTreeEnabled, isJoinedToTransaction, isOpenOrWaitingForAutoClose, isTransactionInProgress, joinTransaction, markForRollbackOnly, prepareForAutoClose, prepareForQueryExecution, setCacheMode, setClosed, setCriteriaCopyTreeEnabled, setHibernateFlushMode, setJdbcBatchSize, setNativeJdbcParametersIgnored, setUpMultitenancy, shouldAutoJoinTransaction, useStreamForLobBindingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jakarta.persistence.EntityManager
createNativeQuery, createNativeQuery, createNativeQuery, getCriteriaBuilder, getTransaction, isJoinedToTransaction, joinTransactionMethods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getEventManager, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcSessionContext, getSqlExceptionHelper, getTransactionCoordinatorMethods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
execute, fromContextMethods inherited from interface org.hibernate.query.QueryProducer
createMutationQuery, createMutationQuery, createNamedSelectionQuery, createNamedSelectionQuery, createSelectionQuery, createSelectionQuery, createSelectionQueryMethods inherited from interface org.hibernate.query.spi.QueryProducerImplementor
createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, createQuery, createQuery, createQuery, createQuery, createQuery, getNamedNativeQuery, getNamedNativeQuery, getNamedQueryMethods inherited from interface org.hibernate.Session
callWithConnection, createNamedQuery, createNamedQuery, createQuery, createQuery, createQuery, createQuery, createQuery, createQuery, disableFilter, enableFilter, getCacheMode, getEnabledFilter, getEntityGraphs, getFlushMode, getHibernateFlushMode, runWithConnection, setCacheMode, setHibernateFlushModeMethods inherited from interface org.hibernate.engine.spi.SessionImplementor
asSessionImplementor, createEntityGraph, createEntityGraph, getEntityGraph, isSessionImplementorMethods inherited from interface org.hibernate.SharedSessionContract
beginTransaction, createEntityGraph, doReturningWork, doWork, getCriteriaBuilder, getJdbcBatchSize, getNamedProcedureCall, getTenantIdentifier, getTenantIdentifierValue, getTransaction, isConnected, isJoinedToTransaction, joinTransaction, setJdbcBatchSizeMethods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
accessTransaction, asStatelessSession, checkOpen, checkOpen, checkTransactionNeededForUpdateOperation, generateEntityKey, getCacheMode, getCacheTransactionSynchronization, getConfiguredJdbcBatchSize, getEventListenerManager, getExceptionConverter, getFactory, getFlushMode, getHibernateFlushMode, getInterceptor, getJdbcCoordinator, getJdbcServices, getNativeJdbcParametersIgnored, getSessionIdentifier, getSessionToken, getTypeConfiguration, isClosed, isCriteriaCopyTreeEnabled, isOpenOrWaitingForAutoClose, isStatelessSession, isTransactionInProgress, markForRollbackOnly, prepareForQueryExecution, setCacheMode, setCriteriaCopyTreeEnabled, setHibernateFlushMode, setNativeJdbcParametersIgnoredMethods inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options
shouldAutoJoinTransactionMethods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect, getJdbcTimeZone, getLobCreator, getPreferredSqlTypeCodeForBoolean, useStreamForLobBinding
-
Constructor Details
-
SessionImpl
-
-
Method Details
-
createPersistenceContext
-
createActionQueue
-
applyQuerySettingsAndHints
- Overrides:
applyQuerySettingsAndHintsin classAbstractSharedSessionContract
-
applyLockOptionsHint
-
applyQuerySettingsAndHints
- Overrides:
applyQuerySettingsAndHintsin classAbstractSharedSessionContract
-
sessionWithOptions
Description copied from interface:SessionObtain aSessionbuilder with the ability to copy certain information from this session.- Specified by:
sessionWithOptionsin interfaceSession- Returns:
- the session builder
-
clear
public void clear()Description copied from interface:SessionCompletely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open iterators or instances ofScrollableResults.- Specified by:
clearin interfaceEntityManager- Specified by:
clearin interfaceSession
-
close
Description copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEntityManager- Specified by:
closein interfaceSharedSessionContract- Overrides:
closein classAbstractSharedSessionContract- Throws:
HibernateException- Indicates problems cleaning up.
-
closeWithoutOpenChecks
- Throws:
HibernateException
-
shouldCloseJdbcCoordinatorOnClose
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) - Overrides:
shouldCloseJdbcCoordinatorOnClosein classAbstractSharedSessionContract
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()Description copied from interface:SharedSessionContractImplementorIs auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabledin interfaceSharedSessionContractImplementor- See Also:
-
isOpen
public boolean isOpen()Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfaceEntityManager- Specified by:
isOpenin interfaceSharedSessionContract- Overrides:
isOpenin classAbstractSharedSessionContract- Returns:
- boolean
-
checkSessionFactoryOpen
protected void checkSessionFactoryOpen() -
shouldAutoClose
public boolean shouldAutoClose()Description copied from interface:SharedSessionContractImplementorShould this session be automatically closed after the current transaction completes?- Specified by:
shouldAutoClosein interfaceSharedSessionContractImplementor
-
setAutoClear
public void setAutoClear(boolean enabled) Description copied from interface:SharedSessionContractImplementorEnable or disable automatic cache clearing from after transaction completion.- Specified by:
setAutoClearin interfaceSharedSessionContractImplementor
-
afterOperation
public void afterOperation(boolean success) Description copied from interface:SharedSessionContractImplementorCheck 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:
afterOperationin interfaceLoadAccessContext- Specified by:
afterOperationin interfaceSharedSessionContractImplementor- Parameters:
success-trueif the operation a success
-
addEventListeners
Description copied from interface:SessionAdd one or more listeners to the Session- Specified by:
addEventListenersin interfaceSession- Parameters:
listeners- the listener(s) to add
-
cleanupOnClose
protected void cleanupOnClose()clear all the internal collections, just to help the garbage collector, does not clear anything that is needed during the afterTransactionCompletion() phase- Overrides:
cleanupOnClosein classAbstractSharedSessionContract
-
getCurrentLockMode
Description copied from interface:SessionDetermine the currentLockModeof the given managed instance associated with this session.- Specified by:
getCurrentLockModein interfaceSession- Parameters:
object- a persistent instance associated with this session- Returns:
- the current lock mode
- Throws:
HibernateException
-
getEntityUsingInterceptor
Description copied from interface:SharedSessionContractImplementorGet the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.- Specified by:
getEntityUsingInterceptorin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
checkNoUnresolvedActionsBeforeOperation
protected void checkNoUnresolvedActionsBeforeOperation() -
checkNoUnresolvedActionsAfterOperation
protected void checkNoUnresolvedActionsAfterOperation() -
delayedAfterCompletion
public void delayedAfterCompletion()- Specified by:
delayedAfterCompletionin interfaceLoadAccessContext- Overrides:
delayedAfterCompletionin classAbstractSharedSessionContract
-
pulseTransactionCoordinator
public void pulseTransactionCoordinator()Description copied from interface:LoadAccessContextCallback to pulse the transaction coo- Specified by:
pulseTransactionCoordinatorin interfaceLoadAccessContext- Overrides:
pulseTransactionCoordinatorin classAbstractSharedSessionContract
-
checkOpenOrWaitingForAutoClose
public void checkOpenOrWaitingForAutoClose()Description copied from interface:LoadAccessContextCallback to check whether the session is "active"- Specified by:
checkOpenOrWaitingForAutoClosein interfaceLoadAccessContext- Overrides:
checkOpenOrWaitingForAutoClosein classAbstractSharedSessionContract
-
lock
Description copied from interface:SessionObtain a lock on the given managed instance associated with this session, using the given lock options.This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK. -
lock
Description copied from interface:SessionImplementorCascade the lock operation to the given child entity.- Specified by:
lockin interfaceSessionImplementor
-
lock
Description copied from interface:SessionObtain the specified lock level on the given managed instance associated with this session. This may be used to:- perform a version check with
LockMode.READ, or - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_WRITE).
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK.- Specified by:
lockin interfaceSession- Parameters:
entityName- the name of the entityobject- a persistent instance associated with this sessionlockMode- the lock level- Throws:
HibernateException
- perform a version check with
-
buildLockRequest
Deprecated.Description copied from interface:SessionBuild a new lock request that specifies:- the
LockModeto use, - the pessimistic lock timeout, and
- the scope that is, whether the lock extends to rows of owned collections.
Timeout and scope are ignored if the specified
LockModerepresents a flavor of optimistic locking.Call
Session.LockRequest.lock(Object)to actually obtain the requested lock on a managed entity instance.- Specified by:
buildLockRequestin interfaceSession- Parameters:
lockOptions- contains the lock level- Returns:
- a
Session.LockRequestthat can be used to lock any given object.
- the
-
lock
Description copied from interface:SessionObtain the specified lock level on the given managed instance associated with this session. This operation may be used to:- perform a version check on an entity read from the second-level cache
by requesting
LockMode.READ, - schedule a version check at transaction commit by requesting
LockMode.OPTIMISTIC, - schedule a version increment at transaction commit by requesting
LockMode.OPTIMISTIC_FORCE_INCREMENT - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_READorLockMode.PESSIMISTIC_WRITE, or - immediately increment the version of the given instance by requesting
LockMode.PESSIMISTIC_FORCE_INCREMENT.
If the requested lock mode is already held on the given entity, this operation has no effect.
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK.The modes
LockMode.WRITEandLockMode.UPGRADE_SKIPLOCKEDare not legal arguments tolock().- Specified by:
lockin interfaceSession- Parameters:
object- a persistent instancelockMode- the lock level- Throws:
HibernateException
- perform a version check on an entity read from the second-level cache
by requesting
-
persist
Description copied from interface:SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST.For entities with a
generated id,persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.- Specified by:
persistin interfaceSession- Parameters:
entityName- the entity nameobject- a transient instance to be made persistent- Throws:
HibernateException
-
persist
Description copied from interface:SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST.For an entity with a generated id,
persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.- Specified by:
persistin interfaceEntityManager- Specified by:
persistin interfaceSession- Parameters:
object- a transient instance to be made persistent- Throws:
HibernateException
-
persist
public void persist(String entityName, Object object, PersistContext copiedAlready) throws HibernateException Description copied from interface:EventSourceCascade persist an entity instance- Specified by:
persistin interfaceEventSource- Specified by:
persistin interfaceSessionImplementor- Throws:
HibernateException
-
persistOnFlush
Description copied from interface:EventSourceCascade persist an entity instance during the flush process- Specified by:
persistOnFlushin interfaceEventSource- Specified by:
persistOnFlushin interfaceSessionImplementor
-
merge
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped withCascadeType.MERGE.- Specified by:
mergein interfaceSession- Parameters:
entityName- the entity nameobject- a detached instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
merge
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped withCascadeType.MERGE.- Specified by:
mergein interfaceEntityManager- Specified by:
mergein interfaceSession- Parameters:
object- a detached instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
merge
public void merge(String entityName, Object object, MergeContext copiedAlready) throws HibernateException Description copied from interface:EventSourceCascade merge an entity instance- Specified by:
mergein interfaceEventSource- Specified by:
mergein interfaceSessionImplementor- Throws:
HibernateException
-
delete
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) throws HibernateException Description copied from interface:EventSourceCascade delete an entity instance- Specified by:
deletein interfaceEventSource- Throws:
HibernateException
-
removeOrphanBeforeUpdates
Description copied from interface:EventSourceA specialized type of deletion for orphan removal that must occur prior to queued inserts and updates.- Specified by:
removeOrphanBeforeUpdatesin interfaceEventSource- Specified by:
removeOrphanBeforeUpdatesin interfaceSessionImplementor
-
load
Description copied from interface:SessionRead the persistent state associated with the given identifier into the given transient instance.- Specified by:
loadin interfaceSession- Throws:
HibernateException
-
load
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists in the database (use
get()instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.This operation is very similar to
Session.getReference(Class, Object).- Specified by:
loadin interfaceSession- Parameters:
entityClass- a persistent classid- a valid identifier of an existing persistent instance of the class- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists in the database (use
get()instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Specified by:
loadin interfaceSession- Specified by:
loadin classAbstractSharedSessionContract- Parameters:
entityName- the entity nameid- a valid identifier of an existing persistent instance of the class- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.This operation is very similar to
EntityManager.find(Class, Object).The object returned by
get()orfind()is either an unproxied instance of the given entity class, of a fully-fetched proxy object.This operation requests
LockMode.NONE, that is, no lock, allowing the object to be retrieved from the cache without the cost of database access. However, if it is necessary to read the state from the database, the object will be returned with the lock modeLockMode.READ.To bypass the second-level cache, and ensure that the state is read from the database, either:
- call
Session.get(Class, Object, LockMode)with the explicit lock modeLockMode.READ, or - set the cache mode to
CacheMode.IGNOREbefore calling this method.
- Specified by:
getin interfaceSession- Parameters:
entityClass- the entity typeid- an identifier- Returns:
- a persistent instance or null
- Throws:
HibernateException
- call
-
get
Description copied from interface:SessionReturn the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifier- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
immediateLoad
Load the data for the object with the specified id into a newly created object. This is only called when lazily initializing a proxy. Do NOT return a proxy.- Specified by:
immediateLoadin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
internalLoad
Description copied from interface:SharedSessionContractImplementorObtain 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, anullvalue is returned.
When
eager = true, the object is eagerly fetched from the database.- Specified by:
internalLoadin interfaceSharedSessionContractImplementor
- When
-
internalLoadType
-
load
@Deprecated public <T> T load(Class<T> entityClass, Object id, LockMode lockMode) throws HibernateException Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.Convenient form of
Session.load(Class, Object, LockOptions).- Specified by:
loadin interfaceSession- Parameters:
entityClass- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException- See Also:
-
load
@Deprecated public <T> T load(Class<T> entityClass, Object id, LockOptions lockOptions) throws HibernateException Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
loadin interfaceSession- Parameters:
entityClass- a persistent classid- a valid identifier of an existing persistent instance of the classlockOptions- contains the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
@Deprecated public Object load(String entityName, Object id, LockMode lockMode) throws HibernateException Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.Convenient form of
Session.load(String, Object, LockOptions).- Specified by:
loadin interfaceSession- Parameters:
entityName- the entity nameid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException- See Also:
-
load
@Deprecated public Object load(String entityName, Object id, LockOptions lockOptions) throws HibernateException Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
loadin interfaceSession- Parameters:
entityName- the entity nameid- a valid identifier of an existing persistent instance of the classlockOptions- contains the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.Convenient form of
Session.get(Class, Object, LockOptions).This operation is very similar to
EntityManager.find(Class, Object, jakarta.persistence.LockModeType).- Specified by:
getin interfaceSession- Parameters:
entityClass- the entity typeid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException- See Also:
-
get
public <T> T get(Class<T> entityClass, Object id, LockOptions lockOptions) throws HibernateException Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.- Specified by:
getin interfaceSession- Parameters:
entityClass- the entity typeid- an identifierlockOptions- the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.Convenient form of
Session.get(String, Object, LockOptions)- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException- See Also:
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifierlockOptions- contains the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
byId
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve an instance of the named entity type by its primary key.- Specified by:
byIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
IdentifierLoadAccessfor executing the lookup
-
byId
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve an instance of the given entity type by its primary key.- Specified by:
byIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
IdentifierLoadAccessfor executing the lookup
-
byMultipleIds
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their primary key values, using batching.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
MultiIdentifierLoadAccessfor executing the lookup
-
byMultipleIds
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their primary key values, using batching.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
MultiIdentifierLoadAccessfor executing the lookup
-
byNaturalId
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which may be a composite natural id. The entity must have at least one attribute annotatedNaturalId.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
NaturalIdLoadAccessfor executing the lookup
-
byNaturalId
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which may be a composite natural id. The entity must have at least one attribute annotatedNaturalId.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
NaturalIdLoadAccessfor executing the lookup
-
bySimpleNaturalId
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which must be a simple (non-composite) value. The entity must have exactly one attribute annotatedNaturalId.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
SimpleNaturalIdLoadAccessfor executing the lookup
-
bySimpleNaturalId
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which must be a simple (non-composite) value. The entity must have exactly one attribute annotatedNaturalId.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
SimpleNaturalIdLoadAccessfor executing the lookup
-
byMultipleNaturalId
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their by natural id values, using batching.- Specified by:
byMultipleNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
NaturalIdMultiLoadAccessfor executing the lookup
-
byMultipleNaturalId
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their by natural id values, using batching.- Specified by:
byMultipleNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
NaturalIdMultiLoadAccessfor executing the lookup
-
fireLoad
- Specified by:
fireLoadin interfaceLoadAccessContext
-
refresh
Description copied from interface:SessionReread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update,
- after executing any HQL update or delete statement,
- after executing a native SQL statement, or
- after inserting a
BloborClob.
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH.This operation requests
LockMode.READ. To obtain a stronger lock, callSession.refresh(Object, LockMode).- Specified by:
refreshin interfaceEntityManager- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent instance associated with this session- Throws:
HibernateException
-
refresh
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.Convenient form of
Session.refresh(Object, LockOptions)- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent instance associated with this sessionlockMode- the lock mode to use- Throws:
HibernateException- See Also:
-
refresh
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent instance associated with this sessionlockOptions- contains the lock mode to use- Throws:
HibernateException
-
refresh
public void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException Description copied from interface:EventSourceCascade refresh an entity instance- Specified by:
refreshin interfaceEventSource- Throws:
HibernateException
-
replicate
Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withCascadeType.REPLICATE.- Specified by:
replicatein interfaceSession- Parameters:
obj- a detached instance of a persistent classreplicationMode- the replication mode to use- Throws:
HibernateException
-
replicate
public void replicate(String entityName, Object obj, ReplicationMode replicationMode) throws HibernateException Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withCascadeType.REPLICATE.- Specified by:
replicatein interfaceSession- Parameters:
entityName- the entity nameobj- a detached instance of a persistent classreplicationMode- the replication mode to use- Throws:
HibernateException
-
evict
remove any hard references to the entity that are held by the infrastructure (references held by application or other persistent instances are okay)- Specified by:
evictin interfaceSession- Parameters:
object- the managed entity to evict- Throws:
HibernateException
-
autoFlushIfRequired
Description copied from interface:SharedSessionContractImplementordetect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequiredin 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:
autoFlushIfRequiredin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
autoPreFlush
public void autoPreFlush()- Specified by:
autoPreFlushin interfaceSharedSessionContractImplementor
-
isDirty
Description copied from interface:SessionDoes this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?- Specified by:
isDirtyin interfaceSession- Returns:
trueif the session contains pending changes;falseotherwise.- Throws:
HibernateException- could not perform dirtying checking
-
flush
Description copied from interface:SharedSessionContractImplementorFlush this session.- Specified by:
flushin interfaceEntityManager- Specified by:
flushin interfaceSession- Specified by:
flushin interfaceSharedSessionContractImplementor- Throws:
HibernateException- if changes could not be synchronized with the database
-
setFlushMode
Description copied from interface:SessionSet the currentJPA flush modefor this session.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. The current flush mode determines when the session is automatically flushed.
- Specified by:
setFlushModein interfaceEntityManager- Specified by:
setFlushModein interfaceSession- Parameters:
flushModeType- the newFlushModeType- See Also:
-
forceFlush
Description copied from interface:SessionImplementorInitiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlushin interfaceEventSource- Specified by:
forceFlushin interfaceSessionImplementor- Throws:
HibernateException
-
forceFlush
Description copied from interface:SessionImplementorInitiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlushin interfaceEventSource- Specified by:
forceFlushin interfaceSessionImplementor- Throws:
HibernateException
-
instantiate
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class, initializing with the given identifier.- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
instantiate
give the interceptor an opportunity to override the default instantiation- Specified by:
instantiatein interfaceEventSource- Specified by:
instantiatein interfaceSessionImplementor- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getEntityPersister
Description copied from interface:SharedSessionContractImplementorGet theEntityPersisterfor the given entity instance.- Specified by:
getEntityPersisterin interfaceSharedSessionContractImplementor- Parameters:
entityName- optional entity nameobject- the entity instance
-
getIdentifier
Description copied from interface:SessionReturn the identifier value of the given entity associated with this session. An exception is thrown if the given entity instance is transient or detached in relation to this session.- Specified by:
getIdentifierin interfaceSession- Parameters:
object- a persistent instance associated with this session- Returns:
- the identifier
- Throws:
TransientObjectException- if the instance is transient or associated with a different sessionHibernateException
-
getContextEntityIdentifier
Get the id value for an object that is actually associated with the session. This is a bit stricter than getEntityIdentifierIfNotUnsaved().- Specified by:
getContextEntityIdentifierin interfaceSharedSessionContractImplementor
-
contains
- Specified by:
containsin interfaceEntityManager
-
contains
Description copied from interface:SessionDetermine if the given entity is associated with this session. -
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Overrides:
createStoredProcedureCallin classAbstractSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Overrides:
createStoredProcedureCallin classAbstractSharedSessionContract- 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.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Overrides:
createStoredProcedureCallin classAbstractSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
getSessionFactory
Description copied from interface:SharedSessionContractImplementorObtain the factory which created this session.- Specified by:
getSessionFactoryin interfaceSession- Specified by:
getSessionFactoryin interfaceSessionImplementor- Specified by:
getSessionFactoryin interfaceSharedSessionContractImplementor- Specified by:
getSessionFactoryin interfaceWrapperOptions- Returns:
- the session factory
- See Also:
-
createQuery
- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceSessionImplementor
-
initializeCollection
Description copied from interface:SharedSessionContractImplementorInitialize the given collection (if not already initialized).- Specified by:
initializeCollectionin interfaceSharedSessionContractImplementor
-
bestGuessEntityName
Description copied from interface:SharedSessionContractImplementorObtain 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:
bestGuessEntityNamein interfaceSharedSessionContractImplementor
-
bestGuessEntityName
Description copied from interface:SharedSessionContractImplementorObtain 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:
bestGuessEntityNamein interfaceSharedSessionContractImplementor
-
getEntityName
Description copied from interface:SessionReturn the entity name for a persistent entity.- Specified by:
getEntityNamein interfaceSession- Parameters:
object- a persistent entity associated with this session- Returns:
- the entity name
-
getReference
public <T> T getReference(T object) Description copied from interface:SessionReturn a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceEntityManager- Specified by:
getReferencein interfaceSession- Parameters:
object- a detached persistent instance- Returns:
- the persistent instance or proxy
-
guessEntityName
Description copied from interface:SharedSessionContractImplementorObtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.- Specified by:
guessEntityNamein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
cancelQuery
Description copied from interface:SessionCancel the execution of the current query.This is the sole method on session which may be safely called from another thread.
- Specified by:
cancelQueryin interfaceSession- Throws:
HibernateException- if there was a problem cancelling the query
-
toString
-
getActionQueue
Description copied from interface:SessionImplementorGet theActionQueueassociated with this session.- Specified by:
getActionQueuein interfaceEventSource- Specified by:
getActionQueuein interfaceSessionImplementor
-
getPersistenceContext
Description copied from interface:SharedSessionContractImplementorGet the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()for a faster alternative.- Specified by:
getPersistenceContextin interfaceSharedSessionContractImplementor
-
getPersistenceContextInternal
Description copied from interface:SharedSessionContractImplementorSimilar 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:
getPersistenceContextInternalin interfaceSharedSessionContractImplementor- Returns:
- the
PersistenceContextassociated to this session.
-
getStatistics
Description copied from interface:SessionGet the statistics for this session.- Specified by:
getStatisticsin interfaceSession- Returns:
- the session statistics being collected for this session
-
isEventSource
public boolean isEventSource()Description copied from interface:SharedSessionContractImplementorDetermines if this session implementsEventSource.Only stateful session are sources of events. If this object is a stateless session, this method return
false.- Specified by:
isEventSourcein interfaceSharedSessionContractImplementor
-
asEventSource
Description copied from interface:SharedSessionContractImplementorCast this session toEventSourceif possible.Only stateful session are sources of events. If this object is a stateless session, this method throws.
- Specified by:
asEventSourcein interfaceSharedSessionContractImplementor
-
isDefaultReadOnly
public boolean isDefaultReadOnly()Description copied from interface:SharedSessionContractImplementorAre entities and proxies loaded by this session read-only by default?- Specified by:
isDefaultReadOnlyin interfaceSession- Specified by:
isDefaultReadOnlyin interfaceSharedSessionContractImplementor- Returns:
true, loaded entities/proxies will be made read-only by default;false, loaded entities/proxies will be made modifiable by default.- See Also:
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean defaultReadOnly) Description copied from interface:SessionChange the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted.
When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting.
To change the read-only/modifiable setting for a particular entity or proxy that already belongs to this session use
Session.setReadOnly(Object, boolean).To override this session's read-only/modifiable setting for all entities and proxies loaded by a certain
QueryuseQuery.setReadOnly(boolean).- Specified by:
setDefaultReadOnlyin interfaceSession- Parameters:
defaultReadOnly-true, the default for loaded entities/proxies is read-only;false, the default for loaded entities/proxies is modifiable- See Also:
-
isReadOnly
Description copied from interface:SessionIs the specified entity or proxy read-only?To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session use
Session.isDefaultReadOnly()- Specified by:
isReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or proxy- Returns:
trueif the entity or proxy is read-only,falseif the entity or proxy is modifiable.- See Also:
-
setReadOnly
Description copied from interface:SessionSet an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. In read-only mode, no snapshot is maintained, the instance is never dirty checked, and changes are not persisted.If the entity or proxy already has the specified read-only/modifiable setting, then this method does nothing.
To set the default read-only/modifiable setting used for all entities and proxies that are loaded into the session use
Session.setDefaultReadOnly(boolean).To override this session's read-only/modifiable setting for entities and proxies loaded by a
QueryuseQuery.setReadOnly(boolean)- Specified by:
setReadOnlyin interfaceSession- Parameters:
entity- an entity or proxyreadOnly-trueif the entity or proxy should be made read-only;falseif the entity or proxy should be made modifiable- See Also:
-
getCacheStoreMode
Description copied from interface:SessionThe JPA-definedCacheStoreMode.- Specified by:
getCacheStoreModein interfaceEntityManager- Specified by:
getCacheStoreModein interfaceSession- See Also:
-
getCacheRetrieveMode
Description copied from interface:SessionThe JPA-definedCacheRetrieveMode.- Specified by:
getCacheRetrieveModein interfaceEntityManager- Specified by:
getCacheRetrieveModein interfaceSession- See Also:
-
setCacheStoreMode
Description copied from interface:SessionEnable or disable writes to the second-level cache.- Specified by:
setCacheStoreModein interfaceEntityManager- Specified by:
setCacheStoreModein interfaceSession- Parameters:
cacheStoreMode- a JPA-definedCacheStoreMode- See Also:
-
setCacheRetrieveMode
Description copied from interface:SessionEnable or disable reads from the second-level cache.- Specified by:
setCacheRetrieveModein interfaceEntityManager- Specified by:
setCacheRetrieveModein interfaceSession- Parameters:
cacheRetrieveMode- a JPA-definedCacheRetrieveMode- See Also:
-
afterScrollOperation
public void afterScrollOperation()Description copied from interface:SharedSessionContractImplementorCalled 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:
afterScrollOperationin interfaceSharedSessionContractImplementor
-
getLoadQueryInfluencers
Description copied from interface:SharedSessionContractImplementorGet theLoadQueryInfluencersassociated with this session.- Specified by:
getLoadQueryInfluencersin interfaceSharedSessionContractImplementor- Returns:
- the
LoadQueryInfluencersassociated with this session; should never be null.
-
isFetchProfileEnabled
Description copied from interface:SessionIs thefetch profilewith the given name enabled in this session?- Specified by:
isFetchProfileEnabledin interfaceSession- Parameters:
name- the name of the profile- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
-
enableFetchProfile
Description copied from interface:SessionEnable thefetch profilewith the given name in this session. If the requested fetch profile is already enabled, the call has no effect.- Specified by:
enableFetchProfilein interfaceSession- Parameters:
name- the name of the fetch profile to be enabled- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
-
disableFetchProfile
Description copied from interface:SessionDisable thefetch profilewith the given name in this session. If the requested fetch profile is not currently enabled, the call has no effect.- Specified by:
disableFetchProfilein interfaceSession- Parameters:
name- the name of the fetch profile to be disabled- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
-
setSubselectFetchingEnabled
public void setSubselectFetchingEnabled(boolean enabled) Description copied from interface:SessionEnable or disable subselect fetching in this session. Override the factory-level default controlled by the configuration property "hibernate.use_subselect_fetch".- Specified by:
setSubselectFetchingEnabledin interfaceSession- Parameters:
enabled-trueto enable subselect fetching- See Also:
-
isSubselectFetchingEnabled
public boolean isSubselectFetchingEnabled()Description copied from interface:SessionDetermine if subselect fetching is enabled in this session.- Specified by:
isSubselectFetchingEnabledin interfaceSession- Returns:
trueis subselect fetching is enabled
-
setFetchBatchSize
public void setFetchBatchSize(int batchSize) Description copied from interface:SessionSet the maximum batch size for batch fetching associations by id in this session. Override the factory-level default controlled by the configuration property "hibernate.default_batch_fetch_size".- If
batchSize>1, then batch fetching is enabled. - If
batchSize<0, the batch size is inherited from the factory-level setting. - Otherwise, batch fetching is disabled.
- Specified by:
setFetchBatchSizein interfaceSession- Parameters:
batchSize- the maximum batch size for batch fetching- See Also:
- If
-
getFetchBatchSize
public int getFetchBatchSize()Description copied from interface:SessionGet the maximum batch size for batch fetching associations by id in this session.- Specified by:
getFetchBatchSizein interfaceSession
-
getLobHelper
Description copied from interface:Session- Specified by:
getLobHelperin interfaceSession- Returns:
- an instance of
LobHelper
-
beforeTransactionCompletion
public void beforeTransactionCompletion()Description copied from interface:JdbcSessionOwnerA before-completion callback to the owner.- Specified by:
beforeTransactionCompletionin interfaceJdbcSessionOwner- Overrides:
beforeTransactionCompletionin classAbstractSharedSessionContract
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed) Description copied from interface:JdbcSessionOwnerAn after-completion callback to the owner.- Specified by:
afterTransactionCompletionin interfaceJdbcSessionOwner- Overrides:
afterTransactionCompletionin classAbstractSharedSessionContract- Parameters:
successful- Was the transaction successful?delayed- Is this a delayed after transaction completion call (aka after a timeout)?
-
startTransactionBoundary
public void startTransactionBoundary()Description copied from interface:JdbcSessionOwnerCallback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransactionAPI or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction- Specified by:
startTransactionBoundaryin interfaceJdbcSessionOwner- Overrides:
startTransactionBoundaryin classAbstractSharedSessionContract
-
afterTransactionBegin
public void afterTransactionBegin()Description copied from interface:JdbcSessionOwnerA after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBeginin interfaceJdbcSessionOwner
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()- Specified by:
flushBeforeTransactionCompletionin interfaceJdbcSessionOwner
-
getSession
Description copied from interface:SharedSessionContractImplementorReturns this object, fulfilling the contract ofWrapperOptions.- Specified by:
getSessionin interfaceLoadAccessContext- Specified by:
getSessionin interfaceSessionImplementor- Specified by:
getSessionin interfaceSharedSessionContractImplementor- Specified by:
getSessionin interfaceWrapperOptions
-
remove
Description copied from interface:SessionMark a persistence instance associated with this session for removal from the underlying database. Ths operation cascades to associated instances if the association is mappedCascadeType.REMOVE.- Specified by:
removein interfaceEntityManager- Specified by:
removein interfaceSession- Parameters:
entity- the managed persistent instance to remove
-
find
- Specified by:
findin interfaceEntityManager
-
find
- Specified by:
findin interfaceEntityManager
-
find
- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) - Specified by:
findin interfaceEntityManager
-
find
- Specified by:
findin interfaceEntityManager
-
find
- Specified by:
findin interfaceEntityManager
-
determineAppropriateLocalCacheMode
-
getReference
Description copied from interface:SessionReturn a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.Note that
Hibernate.createDetachedProxy(SessionFactory, Class, Object)may be used to obtain a detached reference.It's sometimes necessary to narrow a reference returned by
getReference()to a subtype of the given entity type. A direct Java typecast should never be used in this situation. Instead, the methodHibernate.unproxy(Object, Class)is the recommended way to narrow the type of a proxy object. Alternatively, a new reference may be obtained by simply callinggetReference()again, passing the subtype. Either way, the narrowed reference will usually not be identical to the original reference, when the references are compared using the==operator.- Specified by:
getReferencein interfaceEntityManager- Specified by:
getReferencein interfaceSession- Parameters:
entityClass- the entity typeid- the identifier of a persistent instance that exists in the database- Returns:
- the persistent instance or proxy
-
getReference
Description copied from interface:SessionReturn a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceSession- Parameters:
entityName- the entity nameid- the identifier of a persistent instance that exists in the database- Returns:
- the persistent instance or proxy
-
lock
- Specified by:
lockin interfaceEntityManager
-
lock
- Specified by:
lockin interfaceEntityManager
-
lock
- Specified by:
lockin interfaceEntityManager
-
refresh
- Specified by:
refreshin interfaceEntityManager
-
refresh
- Specified by:
refreshin interfaceEntityManager
-
refresh
- Specified by:
refreshin interfaceEntityManager
-
refresh
- Specified by:
refreshin interfaceEntityManager
-
detach
Description copied from interface:SessionRemove this instance from the session cache. Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped withCascadeType.DETACH.- Specified by:
detachin interfaceEntityManager- Specified by:
detachin interfaceSession- Parameters:
entity- the managed instance to detach
-
getLockMode
- Specified by:
getLockModein interfaceEntityManager
-
setProperty
- Specified by:
setPropertyin interfaceEntityManager
-
getProperties
- Specified by:
getPropertiesin interfaceEntityManager
-
createNamedStoredProcedureQuery
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
createNamedStoredProcedureQueryin interfaceEntityManager- Specified by:
createNamedStoredProcedureQueryin interfaceSharedSessionContract- Overrides:
createNamedStoredProcedureQueryin classAbstractSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Overrides:
createStoredProcedureQueryin classAbstractSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Overrides:
createStoredProcedureQueryin classAbstractSharedSessionContract- 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
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Overrides:
createStoredProcedureQueryin classAbstractSharedSessionContract- 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.
-
unwrap
- Specified by:
unwrapin interfaceEntityManager
-
getDelegate
- Specified by:
getDelegatein interfaceEntityManager
-
getEntityManagerFactory
- Specified by:
getEntityManagerFactoryin interfaceEntityManager
-
getMetamodel
- Specified by:
getMetamodelin interfaceEntityManager
-