Class SessionImpl
- java.lang.Object
- org.hibernate.internal.AbstractSharedSessionContract
- org.hibernate.internal.SessionImpl
- All Implemented Interfaces:
EntityManager,Closeable,Serializable,AutoCloseable,LobCreationContext,SessionImplementor,SharedSessionContractImplementor,EventSource,LoadAccessContext,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,Session,SharedSessionContract,JavaType.CoercionContext,WrapperOptions
public classSessionImplextendsAbstractSharedSessionContractimplementsSerializable,SharedSessionContractImplementor,JdbcSessionOwner,SessionImplementor,EventSource,TransactionCoordinatorBuilder.Options,WrapperOptions,LoadAccessContext
Concrete implementation of theSessionAPI.Exposes two interfaces:
Sessionto the application, andSessionImplementorandEventSource(both SPI interfaces) to other subsystems.
This class is not thread-safe.
- See Also:
- Serialized Form
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 Constructor Description SessionImpl(SessionFactoryImpl factory,SessionCreationOptions options)
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEventListeners(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.voidafterScrollOperation()Called after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context.voidafterTransactionBegin()A 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)EventSourceasEventSource()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)voidautoPreFlush()voidbeforeTransactionCompletion()A before-completion callback to the owner.StringbestGuessEntityName(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.StringbestGuessEntityName(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.Session.LockRequestbuildLockRequest(LockOptions lockOptions)Deprecated.<T> IdentifierLoadAccessImpl<T>byId(Class<T> entityClass)Create anIdentifierLoadAccessinstance to retrieve an instance of the given entity type by its primary key.<T> IdentifierLoadAccessImpl<T>byId(String entityName)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 bynatural id values, using batching.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(String entityName)Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their bynatural id values, using batching.<T> NaturalIdLoadAccess<T>byNaturalId(Class<T> entityClass)Create aNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by itsnatural 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 itsnatural 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 itsnatural 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 itsnatural id, which must be a simple (non-composite) value.voidcancelQuery()Cancel the execution of the current query.protected voidcheckNoUnresolvedActionsAfterOperation()protected voidcheckNoUnresolvedActionsBeforeOperation()voidcheckOpenOrWaitingForAutoClose()Callback to check whether the session is "active"protected voidcheckSessionFactoryOpen()protected voidcleanupOnClose()clear 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.voidcloseWithoutOpenChecks()booleancontains(Object object)booleancontains(String entityName,Object object)Determine if the given entity is associated with this session.protectedActionQueuecreateActionQueue()ProcedureCallcreateNamedStoredProcedureQuery(String name)Obtain aProcedureCallbased on a named templateprotectedStatefulPersistenceContextcreatePersistenceContext()ProcedureCallcreateStoredProcedureCall(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureCall(String procedureName,Class<?>... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureCall(String procedureName,String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureQuery(String procedureName,Class... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName,String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.voiddelayedAfterCompletion()voiddelete(Object object)Deprecated.voiddelete(String entityName,Object object)Deprecated.voiddelete(String entityName,Object object, boolean isCascadeDeleteEnabled,DeleteContext transientEntities)Cascade delete an entity instancevoiddetach(Object entity)Remove this instance from the session cache.protectedCacheModedetermineAppropriateLocalCacheMode(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.voidevict(Object object)remove any hard references to the entity that are held by the infrastructure (references held by application or other persistent instances are okay)<T> Tfind(Class<T> entityClass,Object primaryKey)<T> Tfind(Class<T> entityClass,Object primaryKey,LockModeType lockModeType)<T> Tfind(Class<T> entityClass,Object primaryKey,LockModeType lockModeType,Map<String,Object> properties)<T> Tfind(Class<T> entityClass,Object primaryKey,Map<String,Object> properties)voidfireLoad(LoadEvent event,LoadEventListener.LoadType loadType)voidflush()Flush this session.voidflushBeforeTransactionCompletion()voidforceFlush(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> Tget(Class<T> entityClass,Object id)Return 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,LockMode lockMode)Return 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.Objectget(String entityName,Object id)Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.Objectget(String entityName,Object id,LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.Objectget(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.ActionQueuegetActionQueue()Get theActionQueueassociated with this session.CacheRetrieveModegetCacheRetrieveMode()The JPA-definedCacheRetrieveMode.CacheStoreModegetCacheStoreMode()The JPA-definedCacheStoreMode.ObjectgetContextEntityIdentifier(Object object)Get the id value for an object that is actually associated with the session.LockModegetCurrentLockMode(Object object)Determine the currentLockModeof the given managed instance associated with this session.ObjectgetDelegate()SessionFactoryImplementorgetEntityManagerFactory()StringgetEntityName(Object object)Return the entity name for a persistent entity.EntityPersistergetEntityPersister(String entityName,Object object)Get theEntityPersisterfor the given entity instance.ObjectgetEntityUsingInterceptor(EntityKey key)Get the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.intgetFetchBatchSize()Get the maximum batch size for batch fetching associations by id in this session.ObjectgetIdentifier(Object object)Return the identifier value of the given entity associated with this session.LoadQueryInfluencersgetLoadQueryInfluencers()Get theLoadQueryInfluencersassociated with this session.LobHelpergetLobHelper()LockModeTypegetLockMode(Object entity)MetamodelgetMetamodel()PersistenceContextgetPersistenceContext()Get the persistence context for this session.PersistenceContextgetPersistenceContextInternal()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.Map<String,Object>getProperties()<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.ObjectgetReference(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.SessionImplementorgetSession()Returns this object, fulfilling the contract ofWrapperOptions.SessionFactoryImplementorgetSessionFactory()Obtain thefactory which created this session.SessionStatisticsgetStatistics()Get thestatistics for this session.StringguessEntityName(Object object)Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.ObjectimmediateLoad(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).Objectinstantiate(String entityName,Object id)Instantiate the entity class, initializing with the given identifier.Objectinstantiate(EntityPersister persister,Object id)give the interceptor an opportunity to override the default instantiationObjectinternalLoad(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 staticLoadEventListener.LoadTypeinternalLoadType(boolean eager, boolean nullable)booleanisAutoCloseSessionEnabled()Is auto-close at transaction completion enabled?booleanisDefaultReadOnly()Are 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?booleanisEnforcingFetchGraph()Deprecated, for removal: This API element is subject to removal in a future version.booleanisEventSource()Determines 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?booleanisSubselectFetchingEnabled()Determine if subselect fetching is enabled in this session.<T> Tload(Class<T> entityClass,Object id)Deprecated.<T> Tload(Class<T> entityClass,Object id,LockMode lockMode)Deprecated.<T> Tload(Class<T> entityClass,Object id,LockOptions lockOptions)Deprecated.voidload(Object object,Object id)Read the persistent state associated with the given identifier into the given transient instance.Objectload(String entityName,Object id)Deprecated.Objectload(String entityName,Object id,LockMode lockMode)Deprecated.Objectload(String entityName,Object id,LockOptions lockOptions)Deprecated.voidlock(Object entity,LockModeType lockModeType)voidlock(Object entity,LockModeType lockModeType,Map<String,Object> properties)voidlock(Object object,LockMode lockMode)Obtain 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 givenlock options.voidlock(String entityName,Object object,LockMode lockMode)Obtain 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> Tmerge(String entityName, T object)Copy 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.voidpersist(Object object)Make a transient instance persistent and mark it for later insertion in the database.voidpersist(String entityName,Object object)Make 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 processvoidpulseTransactionCoordinator()Callback to pulse the transaction coovoidrefresh(Object object)Reread the state of the given managed instance associated with this session from the underlying database.voidrefresh(Object entity,LockModeType lockModeType)voidrefresh(Object entity,LockModeType lockModeType,Map<String,Object> properties)voidrefresh(Object entity,Map<String,Object> properties)voidrefresh(Object object,LockMode lockMode)Reread 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)Deprecated.voidrefresh(String entityName,Object object,RefreshContext refreshedAlready)Cascade refresh an entity instancevoidrefresh(String entityName,Object object,LockOptions lockOptions)Deprecated.voidremove(Object entity)Mark 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.Objectsave(Object obj)Deprecated.Objectsave(String entityName,Object object)Deprecated.voidsaveOrUpdate(Object object)Deprecated.voidsaveOrUpdate(String entityName,Object obj)Deprecated.SharedSessionBuildersessionWithOptions()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.voidsetEnforcingFetchGraph(boolean isEnforcingFetchGraph)Deprecated, for removal: This API element is subject to removal in a future version.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.booleanshouldAutoClose()Should this session be automatically closed after the current transaction completes?protected booleanshouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)voidstartTransactionBoundary()Callback 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 TransactionStringtoString()<T> Tunwrap(Class<T> clazz)voidupdate(Object obj)Deprecated.voidupdate(String entityName,Object object)Deprecated.Methods inherited from class org.hibernate.internal.AbstractSharedSessionContract
accessTransaction,addResultType,beginTransaction,buildNamedQuery,buildNamedQuery,checkMutationQuery,checkOpen,checkResultType,checkSelectionQuery,checkTransactionNeededForUpdateOperation,checkTransactionSynchStatus,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,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,useStreamForLobBinding
Methods inherited from class java.lang.Object
clone,equals,finalize,getClass,hashCode,notify,notifyAll,wait,wait,wait
Methods inherited from interface jakarta.persistence.EntityManager
createNativeQuery,createNativeQuery,createNativeQuery,getCriteriaBuilder,getTransaction,isJoinedToTransaction,joinTransaction
Methods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getEventManager,getJdbcBatchSize,getJdbcConnectionAccess,getJdbcSessionContext,getSqlExceptionHelper,getTransactionCoordinator
Methods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
execute,fromContext
Methods inherited from interface org.hibernate.query.QueryProducer
createMutationQuery,createMutationQuery,createNamedSelectionQuery,createNamedSelectionQuery,createSelectionQuery,createSelectionQuery,createSelectionQuery
Methods 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,getNamedNativeQuery,getNamedNativeQuery,getNamedQuery
Methods inherited from interface org.hibernate.Session
createNamedQuery,createNamedQuery,createQuery,createQuery,createQuery,createQuery,createQuery,disableFilter,enableFilter,getCacheMode,getEnabledFilter,getEntityGraphs,getFlushMode,getHibernateFlushMode,setCacheMode,setHibernateFlushMode
Methods inherited from interface org.hibernate.engine.spi.SessionImplementor
asSessionImplementor,createEntityGraph,createEntityGraph,getEntityGraph,isSessionImplementor
Methods inherited from interface org.hibernate.SharedSessionContract
beginTransaction,createEntityGraph,doReturningWork,doWork,getCriteriaBuilder,getJdbcBatchSize,getNamedProcedureCall,getTenantIdentifier,getTenantIdentifierValue,getTransaction,isConnected,isJoinedToTransaction,joinTransaction,setJdbcBatchSize
Methods 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,setNativeJdbcParametersIgnored
Methods inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options
shouldAutoJoinTransaction
Methods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect,getJdbcTimeZone,getLobCreator,getPreferredSqlTypeCodeForBoolean,useStreamForLobBinding
Constructor Detail
SessionImpl
public SessionImpl(SessionFactoryImpl factory,SessionCreationOptions options)
Method Detail
createPersistenceContext
protected StatefulPersistenceContext createPersistenceContext()
createActionQueue
protected ActionQueue createActionQueue()
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(SelectionQuery<?> query)
- Overrides:
applyQuerySettingsAndHintsin classAbstractSharedSessionContract
applyLockOptionsHint
protected void applyLockOptionsHint(SelectionQuery<?> query)
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(Query<?> query)
- Overrides:
applyQuerySettingsAndHintsin classAbstractSharedSessionContract
sessionWithOptions
public SharedSessionBuilder 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
public void close() throwsHibernateException
Description copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntityManager- Specified by:
closein interfaceSharedSessionContract- Overrides:
closein classAbstractSharedSessionContract- Throws:
HibernateException- Indicates problems cleaning up.
closeWithoutOpenChecks
public void closeWithoutOpenChecks() throwsHibernateException
- 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:
TransactionSettings.AUTO_CLOSE_SESSION,SessionFactoryOptions.isAutoCloseSessionEnabled()
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
public void addEventListeners(SessionEventListener... listeners)
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
public LockMode getCurrentLockMode(Object object) throwsHibernateException
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
public Object getEntityUsingInterceptor(EntityKey key) throwsHibernateException
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
saveOrUpdate
@Deprecatedpublic void saveOrUpdate(Object object) throwsHibernateException
Deprecated.Description copied from interface:SessionEitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).This operation cascades to associated instances if the association is mapped with
CascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
object- a transient or detached instance containing new or updated state- Throws:
HibernateException- See Also:
Session.save(Object),Session.update(Object object)
saveOrUpdate
@Deprecatedpublic void saveOrUpdate(String entityName,Object obj) throwsHibernateException
Deprecated.Description copied from interface:SessionEitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).This operation cascades to associated instances if the association is mapped with
CascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
entityName- the entity nameobj- a transient or detached instance containing new or updated state- Throws:
HibernateException- See Also:
Session.save(String,Object),Session.update(String,Object)
save
@Deprecatedpublic Object save(Object obj) throwsHibernateException
Deprecated.Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassignedgenerator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.This operation is very similar to
Session.persist(Object).- Specified by:
savein interfaceSession- Parameters:
obj- a transient instance of a persistent class- Returns:
- the generated identifier
- Throws:
HibernateException
save
@Deprecatedpublic Object save(String entityName,Object object) throwsHibernateException
Deprecated.Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassignedgenerator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.- Specified by:
savein interfaceSession- Parameters:
entityName- the entity nameobject- a transient instance of a persistent class- Returns:
- the generated identifier
- Throws:
HibernateException
update
@Deprecatedpublic void update(Object obj) throwsHibernateException
Deprecated.Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.- Specified by:
updatein interfaceSession- Parameters:
obj- a detached instance containing updated state- Throws:
HibernateException
update
@Deprecatedpublic void update(String entityName,Object object) throwsHibernateException
Deprecated.Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.- Specified by:
updatein interfaceSession- Parameters:
entityName- the entity nameobject- a detached instance containing updated state- Throws:
HibernateException
lock
public void lock(Object object,LockOptions lockOptions)
Description copied from interface:SessionObtain a lock on the given managed instance associated with this session, using the givenlock options.This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK.
lock
public void lock(String entityName,Object object,LockOptions lockOptions)
Description copied from interface:SessionImplementorCascade the lock operation to the given child entity.- Specified by:
lockin interfaceSessionImplementor
lock
public void lock(String entityName,Object object,LockMode lockMode) throwsHibernateException
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
@Deprecatedpublic Session.LockRequest buildLockRequest(LockOptions lockOptions)
Deprecated.Description copied from interface:SessionBuild a newlock request that specifies:- the
LockModeto use, - thepessimistic lock timeout, and
- thescope that is, whether the lock extends to rows of owned collections.
Timeout and scope are ignored if the specified
LockModerepresents a flavor ofoptimistic 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
public void lock(Object object,LockMode lockMode) throwsHibernateException
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
public void persist(String entityName,Object object) throwsHibernateException
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 isflushed, 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
public void persist(Object object) throwsHibernateException
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 agenerated id,
persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session isflushed, 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) throwsHibernateException
Description copied from interface:EventSourceCascade persist an entity instance- Specified by:
persistin interfaceEventSource- Specified by:
persistin interfaceSessionImplementor- Throws:
HibernateException
persistOnFlush
public void persistOnFlush(String entityName,Object object,PersistContext copiedAlready)
Description copied from interface:EventSourceCascade persist an entity instance during the flush process- Specified by:
persistOnFlushin interfaceEventSource- Specified by:
persistOnFlushin interfaceSessionImplementor
merge
public <T> T merge(String entityName, T object) throwsHibernateException
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
public <T> T merge(T object) throwsHibernateException
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) throwsHibernateException
Description copied from interface:EventSourceCascade merge an entity instance- Specified by:
mergein interfaceEventSource- Specified by:
mergein interfaceSessionImplementor- Throws:
HibernateException
delete
@Deprecatedpublic void delete(Object object) throwsHibernateException
Deprecated.Description copied from interface:SessionRemove a persistent instance from the datastore. The argument may be an instance associated with the receivingSessionor a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withCascadeType.REMOVE.- Specified by:
deletein interfaceSession- Parameters:
object- the instance to be removed- Throws:
HibernateException
delete
@Deprecatedpublic void delete(String entityName,Object object) throwsHibernateException
Deprecated.Description copied from interface:SessionRemove a persistent instance from the datastore. The second argument may be an instance associated with the receivingSessionor a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withCascadeType.REMOVE.- Specified by:
deletein interfaceSession- Parameters:
entityName- the entity name for the instance to be removed.object- the instance to be removed- Throws:
HibernateException
delete
public void delete(String entityName,Object object, boolean isCascadeDeleteEnabled,DeleteContext transientEntities) throwsHibernateException
Description copied from interface:EventSourceCascade delete an entity instance- Specified by:
deletein interfaceEventSource- Specified by:
deletein interfaceSessionImplementor- Throws:
HibernateException
removeOrphanBeforeUpdates
public void removeOrphanBeforeUpdates(String entityName,Object child)
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
public void load(Object object,Object id) throwsHibernateException
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
@Deprecatedpublic <T> T load(Class<T> entityClass,Object id) throwsHibernateException
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
@Deprecatedpublic Object load(String entityName,Object id) throwsHibernateException
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
public <T> T get(Class<T> entityClass,Object id) throwsHibernateException
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
public Object get(String entityName,Object id) throwsHibernateException
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
public Object immediateLoad(String entityName,Object id) throwsHibernateException
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
public Object internalLoad(String entityName,Object id, boolean eager, boolean nullable)
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
protected static LoadEventListener.LoadType internalLoadType(boolean eager, boolean nullable)
load
@Deprecatedpublic <T> T load(Class<T> entityClass,Object id,LockMode lockMode) throwsHibernateException
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:
Session.load(Class, Object, LockOptions)
load
@Deprecatedpublic <T> T load(Class<T> entityClass,Object id,LockOptions lockOptions) throwsHibernateException
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
@Deprecatedpublic Object load(String entityName,Object id,LockMode lockMode) throwsHibernateException
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:
Session.load(String, Object, LockOptions)
load
@Deprecatedpublic Object load(String entityName,Object id,LockOptions lockOptions) throwsHibernateException
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
public <T> T get(Class<T> entityClass,Object id,LockMode lockMode) throwsHibernateException
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:
Session.get(Class, Object, LockOptions)
get
public <T> T get(Class<T> entityClass,Object id,LockOptions lockOptions) throwsHibernateException
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
public Object get(String entityName,Object id,LockMode lockMode) throwsHibernateException
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:
Session.get(String, Object, LockOptions)
get
public Object get(String entityName,Object id,LockOptions lockOptions) throwsHibernateException
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
public <T> IdentifierLoadAccessImpl<T> byId(String entityName)
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
public <T> IdentifierLoadAccessImpl<T> byId(Class<T> entityClass)
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
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
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
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(String entityName)
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
public <T> NaturalIdLoadAccess<T> byNaturalId(String entityName)
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by itsnatural 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
public <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by itsnatural 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
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(String entityName)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by itsnatural 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
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by itsnatural 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
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their bynatural 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
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(String entityName)
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their bynatural 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
public void fireLoad(LoadEvent event,LoadEventListener.LoadType loadType)
- Specified by:
fireLoadin interfaceLoadAccessContext
refresh
public void refresh(Object object) throwsHibernateException
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,
- afterexecuting any HQL update or delete statement,
- afterexecuting 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
@Deprecatedpublic void refresh(String entityName,Object object) throwsHibernateException
Deprecated.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,
- afterexecuting any HQL update or delete statement,
- afterexecuting a native SQL statement, or
- after inserting a
BloborClob.
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH.- Specified by:
refreshin interfaceSession- Parameters:
entityName- the name of the entityobject- a persistent instance associated with this session- Throws:
HibernateException
refresh
public void refresh(Object object,LockMode lockMode) throwsHibernateException
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:
Session.refresh(Object, LockOptions)
refresh
public void refresh(Object object,LockOptions lockOptions) throwsHibernateException
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
@Deprecatedpublic void refresh(String entityName,Object object,LockOptions lockOptions) throwsHibernateException
Deprecated.Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.- Specified by:
refreshin interfaceSession- Parameters:
entityName- the name of the entityobject- 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) throwsHibernateException
Description copied from interface:EventSourceCascade refresh an entity instance- Specified by:
refreshin interfaceEventSource- Specified by:
refreshin interfaceSessionImplementor- Throws:
HibernateException
replicate
public void replicate(Object obj,ReplicationMode replicationMode) throwsHibernateException
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) throwsHibernateException
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
public void evict(Object object) throwsHibernateException
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
public boolean autoFlushIfRequired(Set<String> querySpaces) throwsHibernateException
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) throwsHibernateException
- Specified by:
autoFlushIfRequiredin interfaceSharedSessionContractImplementor- Throws:
HibernateException
autoPreFlush
public void autoPreFlush()
- Specified by:
autoPreFlushin interfaceSharedSessionContractImplementor
isDirty
public boolean isDirty() throwsHibernateException
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
public void flush() throwsHibernateException
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
public void setFlushMode(FlushModeType flushModeType)
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:
for additional options
forceFlush
public void forceFlush(EntityEntry entityEntry) throwsHibernateException
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
public void forceFlush(EntityKey key) throwsHibernateException
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
public Object instantiate(String entityName,Object id) throwsHibernateException
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class, initializing with the given identifier.- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
instantiate
public Object instantiate(EntityPersister persister,Object id) throwsHibernateException
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
public EntityPersister getEntityPersister(String entityName,Object object)
Description copied from interface:SharedSessionContractImplementorGet theEntityPersisterfor the given entity instance.- Specified by:
getEntityPersisterin interfaceSharedSessionContractImplementor- Parameters:
entityName- optional entity nameobject- the entity instance
getIdentifier
public Object getIdentifier(Object object) throwsHibernateException
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
public Object getContextEntityIdentifier(Object object)
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
public boolean contains(Object object)
- Specified by:
containsin interfaceEntityManager
contains
public boolean contains(String entityName,Object object)
Description copied from interface:SessionDetermine if the given entity is associated with this session.
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName)
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
public ProcedureCall createStoredProcedureCall(String procedureName,String... resultSetMappings)
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
public ProcedureCall createStoredProcedureCall(String procedureName,Class<?>... resultClasses)
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
public SessionFactoryImplementor getSessionFactory()
Description copied from interface:SharedSessionContractImplementorObtain thefactory 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:
SessionFactory
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing)
Description copied from interface:SharedSessionContractImplementorInitialize the given collection (if not already initialized).- Specified by:
initializeCollectionin interfaceSharedSessionContractImplementor
bestGuessEntityName
public String bestGuessEntityName(Object object)
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
public String bestGuessEntityName(Object object,EntityEntry entry)
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
public String getEntityName(Object object)
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 interfaceSession- Parameters:
object- a detached persistent instance- Returns:
- the persistent instance or proxy
guessEntityName
public String guessEntityName(Object object) throwsHibernateException
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
public void cancelQuery() throwsHibernateException
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
getActionQueue
public ActionQueue getActionQueue()
Description copied from interface:SessionImplementorGet theActionQueueassociated with this session.- Specified by:
getActionQueuein interfaceEventSource- Specified by:
getActionQueuein interfaceSessionImplementor
getPersistenceContext
public PersistenceContext getPersistenceContext()
Description copied from interface:SharedSessionContractImplementorGet the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()for a faster alternative.- Specified by:
getPersistenceContextin interfaceSharedSessionContractImplementor
getPersistenceContextInternal
public PersistenceContext 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
public SessionStatistics getStatistics()
Description copied from interface:SessionGet thestatistics 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
public EventSource 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:
Session.isReadOnly(Object)
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:
Session.setReadOnly(Object,boolean),Query.setReadOnly(boolean)
isReadOnly
public boolean isReadOnly(Object entityOrProxy)
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:
Session.isDefaultReadOnly()
setReadOnly
public void setReadOnly(Object entity, boolean readOnly)
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:
Session.setDefaultReadOnly(boolean),Query.setReadOnly(boolean),IdentifierLoadAccess.withReadOnly(boolean)
getCacheStoreMode
public CacheStoreMode getCacheStoreMode()
Description copied from interface:SessionThe JPA-definedCacheStoreMode.- Specified by:
getCacheStoreModein interfaceSession- See Also:
Session.getCacheMode()
getCacheRetrieveMode
public CacheRetrieveMode getCacheRetrieveMode()
Description copied from interface:SessionThe JPA-definedCacheRetrieveMode.- Specified by:
getCacheRetrieveModein interfaceSession- See Also:
Session.getCacheMode()
setCacheStoreMode
public void setCacheStoreMode(CacheStoreMode cacheStoreMode)
Description copied from interface:SessionEnable or disable writes to the second-level cache.- Specified by:
setCacheStoreModein interfaceSession- Parameters:
cacheStoreMode- a JPA-definedCacheStoreMode- See Also:
Session.setCacheMode(CacheMode)
setCacheRetrieveMode
public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
Description copied from interface:SessionEnable or disable reads from the second-level cache.- Specified by:
setCacheRetrieveModein interfaceSession- Parameters:
cacheRetrieveMode- a JPA-definedCacheRetrieveMode- See Also:
Session.setCacheMode(CacheMode)
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
public LoadQueryInfluencers 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
public boolean isFetchProfileEnabled(String name) throwsUnknownProfileException
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:
FetchProfile
enableFetchProfile
public void enableFetchProfile(String name) throwsUnknownProfileException
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:
FetchProfile
disableFetchProfile
public void disableFetchProfile(String name) throwsUnknownProfileException
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:
FetchProfile
setSubselectFetchingEnabled
public void setSubselectFetchingEnabled(boolean enabled)
Description copied from interface:SessionEnable or disable subselect fetching in this session. Override thefactory-level default controlled by the configuration property"hibernate.use_subselect_fetch".- Specified by:
setSubselectFetchingEnabledin interfaceSession- Parameters:
enabled-trueto enable subselect fetching- See Also:
FetchSettings.USE_SUBSELECT_FETCH
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 thefactory-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:
FetchSettings.DEFAULT_BATCH_FETCH_SIZE
- 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
public LobHelper 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)?
addSharedSessionTransactionObserver
protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
- Overrides:
addSharedSessionTransactionObserverin classAbstractSharedSessionContract
removeSharedSessionTransactionObserver
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
- Overrides:
removeSharedSessionTransactionObserverin classAbstractSharedSessionContract
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
public SessionImplementor 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
public void remove(Object entity)
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
public <T> T find(Class<T> entityClass,Object primaryKey)
- Specified by:
findin interfaceEntityManager
find
public <T> T find(Class<T> entityClass,Object primaryKey,Map<String,Object> properties)
- Specified by:
findin interfaceEntityManager
find
public <T> T find(Class<T> entityClass,Object primaryKey,LockModeType lockModeType)
- Specified by:
findin interfaceEntityManager
find
public <T> T find(Class<T> entityClass,Object primaryKey,LockModeType lockModeType,Map<String,Object> properties)
- Specified by:
findin interfaceEntityManager
determineAppropriateLocalCacheMode
protected CacheMode determineAppropriateLocalCacheMode(Map<String,Object> localProperties)
getReference
public <T> T getReference(Class<T> entityClass,Object id)
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 adetached 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
public Object getReference(String entityName,Object id)
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
public void lock(Object entity,LockModeType lockModeType)
- Specified by:
lockin interfaceEntityManager
lock
public void lock(Object entity,LockModeType lockModeType,Map<String,Object> properties)
- Specified by:
lockin interfaceEntityManager
refresh
public void refresh(Object entity,Map<String,Object> properties)
- Specified by:
refreshin interfaceEntityManager
refresh
public void refresh(Object entity,LockModeType lockModeType)
- Specified by:
refreshin interfaceEntityManager
refresh
public void refresh(Object entity,LockModeType lockModeType,Map<String,Object> properties)
- Specified by:
refreshin interfaceEntityManager
detach
public void detach(Object entity)
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
public LockModeType getLockMode(Object entity)
- Specified by:
getLockModein interfaceEntityManager
setProperty
public void setProperty(String propertyName,Object value)
- Specified by:
setPropertyin interfaceEntityManager
getProperties
public Map<String,Object> getProperties()
- Specified by:
getPropertiesin interfaceEntityManager
createNamedStoredProcedureQuery
public ProcedureCall createNamedStoredProcedureQuery(String name)
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:
NamedStoredProcedureQuery
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName)
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
public ProcedureCall createStoredProcedureQuery(String procedureName,Class... resultClasses)
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
public ProcedureCall createStoredProcedureQuery(String procedureName,String... resultSetMappings)
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
public <T> T unwrap(Class<T> clazz)
- Specified by:
unwrapin interfaceEntityManager
getDelegate
public Object getDelegate()
- Specified by:
getDelegatein interfaceEntityManager
getEntityManagerFactory
public SessionFactoryImplementor getEntityManagerFactory()
- Specified by:
getEntityManagerFactoryin interfaceEntityManager
getMetamodel
public Metamodel getMetamodel()
- Specified by:
getMetamodelin interfaceEntityManager
isEnforcingFetchGraph
@Deprecated(forRemoval=true)public boolean isEnforcingFetchGraph()
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:SharedSessionContractImplementorAre we currently enforcing afetch graph?- Specified by:
isEnforcingFetchGraphin interfaceSharedSessionContractImplementor
setEnforcingFetchGraph
@Deprecated(forRemoval=true)public void setEnforcingFetchGraph(boolean isEnforcingFetchGraph)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:SharedSessionContractImplementorEnable or disablefetch graph enforcement.- Specified by:
setEnforcingFetchGraphin interfaceSharedSessionContractImplementor