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 class SessionImpl extends AbstractSharedSessionContract implements Serializable, SharedSessionContractImplementor, JdbcSessionOwner, SessionImplementor, EventSource, TransactionCoordinatorBuilder.Options, WrapperOptions, LoadAccessContext
Concrete implementation of theSession
API.Exposes two interfaces:
Session
to the application, andSessionImplementor
andEventSource
(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 void
addEventListeners(SessionEventListener... listeners)
Add one or more listeners to the Sessionprotected void
addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
void
afterOperation(boolean success)
Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.void
afterScrollOperation()
Called after each operation on aScrollableResults
, providing an opportunity for a stateless session to clear its temporary persistence context.void
afterTransactionBegin()
A after-begin callback from the coordinator to its owner.void
afterTransactionCompletion(boolean successful, boolean delayed)
An after-completion callback to the owner.protected void
applyLockOptionsHint(SelectionQuery<?> query)
protected void
applyQuerySettingsAndHints(Query<?> query)
protected void
applyQuerySettingsAndHints(SelectionQuery<?> query)
EventSource
asEventSource()
Cast this session toEventSource
if possible.boolean
autoFlushIfRequired(Set<String> querySpaces)
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushvoid
beforeTransactionCompletion()
A before-completion callback to the owner.String
bestGuessEntityName(Object object)
Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.String
bestGuessEntityName(Object object, EntityEntry entry)
Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.Session.LockRequest
buildLockRequest(LockOptions lockOptions)
Deprecated.<T> IdentifierLoadAccessImpl<T>
byId(Class<T> entityClass)
Create anIdentifierLoadAccess
instance to retrieve the specified entity by primary key.<T> IdentifierLoadAccessImpl<T>
byId(String entityName)
Create anIdentifierLoadAccess
instance to retrieve the specified entity type by primary key.<T> MultiIdentifierLoadAccess<T>
byMultipleIds(Class<T> entityClass)
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.<T> MultiIdentifierLoadAccess<T>
byMultipleIds(String entityName)
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.<T> NaturalIdMultiLoadAccess<T>
byMultipleNaturalId(Class<T> entityClass)
Access to load multiple entities bynatural id
.<T> NaturalIdMultiLoadAccess<T>
byMultipleNaturalId(String entityName)
Access to load multiple entities bynatural id
.<T> NaturalIdLoadAccess<T>
byNaturalId(Class<T> entityClass)
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.<T> NaturalIdLoadAccess<T>
byNaturalId(String entityName)
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.<T> SimpleNaturalIdLoadAccess<T>
bySimpleNaturalId(Class<T> entityClass)
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by its simple (single attribute)natural id
.<T> SimpleNaturalIdLoadAccess<T>
bySimpleNaturalId(String entityName)
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by itsnatural id
.void
cancelQuery()
Cancel the execution of the current query.protected void
checkNoUnresolvedActionsAfterOperation()
protected void
checkNoUnresolvedActionsBeforeOperation()
void
checkOpenOrWaitingForAutoClose()
Callback to check whether the session is "active"protected void
checkSessionFactoryOpen()
protected void
cleanupOnClose()
clear all the internal collections, just to help the garbage collector, does not clear anything that is needed during the afterTransactionCompletion() phasevoid
clear()
Completely clear the session.void
close()
End the session by releasing the JDBC connection and cleaning up.void
closeWithoutOpenChecks()
boolean
contains(Object object)
boolean
contains(String entityName, Object object)
Determine if the given entity is associated with this session.protected ActionQueue
createActionQueue()
<T> RootGraphImplementor<T>
createEntityGraph(Class<T> rootType)
RootGraphImplementor<?>
createEntityGraph(String graphName)
ProcedureCall
createNamedStoredProcedureQuery(String name)
Obtain aProcedureCall
based on a named templateprotected StatefulPersistenceContext
createPersistenceContext()
ProcedureCall
createStoredProcedureCall(String procedureName)
Create aProcedureCall
to a stored procedure.ProcedureCall
createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureCall(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName)
Create aProcedureCall
to a stored procedure.ProcedureCall
createStoredProcedureQuery(String procedureName, Class... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.void
delayedAfterCompletion()
void
delete(Object object)
Deprecated.void
delete(String entityName, Object object)
Deprecated.void
delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
Cascade delete an entity instancevoid
detach(Object entity)
Remove this instance from the session cache.protected CacheMode
determineAppropriateLocalCacheMode(Map<String,Object> localProperties)
void
disableFetchProfile(String name)
Disable thefetch profile
with the given name in this session.void
disableFilter(String filterName)
Disable the named filter for the current session.void
enableFetchProfile(String name)
Enable thefetch profile
with the given name in this session.Filter
enableFilter(String filterName)
Enable the named filter for this current session.void
evict(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> T
find(Class<T> entityClass, Object primaryKey)
<T> T
find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType)
<T> T
find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String,Object> properties)
<T> T
find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
void
fireLoad(LoadEvent event, LoadEventListener.LoadType loadType)
void
flush()
Flush this session.void
flushBeforeTransactionCompletion()
void
forceFlush(EntityEntry entityEntry)
Initiate a flush to force deletion of a re-persisted entity.void
forceFlush(EntityKey key)
Initiate a flush to force deletion of a re-persisted entity.<T> T
get(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> T
get(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> T
get(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.Object
get(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.Object
get(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.Object
get(String entityName, Object id, LockOptions lockOptions)
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.ActionQueue
getActionQueue()
Get theActionQueue
associated with this session.CacheRetrieveMode
getCacheRetrieveMode()
The JPA-definedCacheRetrieveMode
.CacheStoreMode
getCacheStoreMode()
The JPA-definedCacheStoreMode
.Object
getContextEntityIdentifier(Object object)
Get the id value for an object that is actually associated with the session.LockMode
getCurrentLockMode(Object object)
Determine the currentLockMode
of the given managed instance associated with this session.Object
getDelegate()
Filter
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.RootGraphImplementor<?>
getEntityGraph(String graphName)
<T> List<EntityGraph<? super T>>
getEntityGraphs(Class<T> entityClass)
SessionFactoryImplementor
getEntityManagerFactory()
String
getEntityName(Object object)
Return the entity name for a persistent entity.EntityPersister
getEntityPersister(String entityName, Object object)
Get theEntityPersister
for the given entity instance.Object
getEntityUsingInterceptor(EntityKey key)
Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.Object
getIdentifier(Object object)
Return the identifier value of the given entity associated with this session.LoadQueryInfluencers
getLoadQueryInfluencers()
Get theLoadQueryInfluencers
associated with this session.LobHelper
getLobHelper()
LockModeType
getLockMode(Object entity)
Metamodel
getMetamodel()
PersistenceContext
getPersistenceContext()
Get the persistence context for this session.PersistenceContext
getPersistenceContextInternal()
Similar toSharedSessionContractImplementor.getPersistenceContext()
, with two differences: this version performs better as it allows for inlining and probably better prediction, and it skips some checks of the current state of the session.Map<String,Object>
getProperties()
<T> T
getReference(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.Object
getReference(String entityName, Object id)
Return a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database.<T> T
getReference(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.SessionImplementor
getSession()
Returns this object, fulfilling the contract ofWrapperOptions
.SessionFactoryImplementor
getSessionFactory()
Obtain the factory which created this session.SessionStatistics
getStatistics()
Get the statistics for this session.String
guessEntityName(Object object)
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.Object
immediateLoad(String entityName, Object id)
Load the data for the object with the specified id into a newly created object.void
initializeCollection(PersistentCollection<?> collection, boolean writing)
Initialize the given collection (if not already initialized).Object
instantiate(String entityName, Object id)
Instantiate the entity class, initializing with the given identifier.Object
instantiate(EntityPersister persister, Object id)
give the interceptor an opportunity to override the default instantiationObject
internalLoad(String entityName, Object id, boolean eager, boolean nullable)
Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.protected static LoadEventListener.LoadType
internalLoadType(boolean eager, boolean nullable)
boolean
isAutoCloseSessionEnabled()
Is auto-close at transaction completion enabled?boolean
isDefaultReadOnly()
Are entities and proxies loaded by this session read-only by default?boolean
isDirty()
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?boolean
isEnforcingFetchGraph()
Deprecated, for removal: This API element is subject to removal in a future version.boolean
isEventSource()
Determines if this session implementsEventSource
.boolean
isFetchProfileEnabled(String name)
Is thefetch profile
with the given name enabled in this session?boolean
isOpen()
Check if the session is still open.boolean
isReadOnly(Object entityOrProxy)
Is the specified entity or proxy read-only?<T> T
load(Class<T> entityClass, Object id)
Deprecated.<T> T
load(Class<T> entityClass, Object id, LockMode lockMode)
Deprecated.<T> T
load(Class<T> entityClass, Object id, LockOptions lockOptions)
Deprecated.void
load(Object object, Object id)
Read the persistent state associated with the given identifier into the given transient instance.Object
load(String entityName, Object id)
Deprecated.Object
load(String entityName, Object id, LockMode lockMode)
Deprecated.Object
load(String entityName, Object id, LockOptions lockOptions)
Deprecated.void
lock(Object entity, LockModeType lockModeType)
void
lock(Object entity, LockModeType lockModeType, Map<String,Object> properties)
void
lock(Object object, LockMode lockMode)
Obtain the specified lock level on the given managed instance associated with this session.void
lock(Object object, LockOptions lockOptions)
Obtain a lock on the given managed instance associated with this session, using the givenlock options
.void
lock(String entityName, Object object, LockMode lockMode)
Obtain the specified lock level on the given managed instance associated with this session.void
lock(String entityName, Object object, LockOptions lockOptions)
Cascade the lock operation to the given child entity.void
merge(String entityName, Object object, MergeContext copiedAlready)
Cascade merge an entity instance<T> T
merge(String entityName, T object)
Copy the state of the given object onto the persistent object with the same identifier.<T> T
merge(T object)
Copy the state of the given object onto the persistent object with the same identifier.void
persist(Object object)
Make a transient instance persistent and mark it for later insertion in the database.void
persist(String entityName, Object object)
Make a transient instance persistent and mark it for later insertion in the database.void
persist(String entityName, Object object, PersistContext copiedAlready)
Cascade persist an entity instancevoid
persistOnFlush(String entityName, Object object, PersistContext copiedAlready)
Cascade persist an entity instance during the flush processvoid
pulseTransactionCoordinator()
Callback to pulse the transaction coovoid
refresh(Object object)
Reread the state of the given managed instance associated with this session from the underlying database.void
refresh(Object entity, LockModeType lockModeType)
void
refresh(Object entity, LockModeType lockModeType, Map<String,Object> properties)
void
refresh(Object entity, Map<String,Object> properties)
void
refresh(Object object, LockMode lockMode)
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.void
refresh(Object object, LockOptions lockOptions)
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.void
refresh(String entityName, Object object)
Deprecated.void
refresh(String entityName, Object object, RefreshContext refreshedAlready)
Cascade refresh an entity instancevoid
refresh(String entityName, Object object, LockOptions lockOptions)
Deprecated.void
remove(Object entity)
Mark a persistence instance associated with this session for removal from the underlying database.void
removeOrphanBeforeUpdates(String entityName, Object child)
A specialized type of deletion for orphan removal that must occur prior to queued inserts and updates.protected void
removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
void
replicate(Object obj, ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current identifier value.void
replicate(String entityName, Object obj, ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current identifier value.Object
save(Object obj)
Deprecated.Object
save(String entityName, Object object)
Deprecated.void
saveOrUpdate(Object object)
Deprecated.void
saveOrUpdate(String entityName, Object obj)
Deprecated.SharedSessionBuilder
sessionWithOptions()
Obtain aSession
builder with the ability to copy certain information from this session.void
setAutoClear(boolean enabled)
Enable or disable automatic cache clearing from after transaction completion.void
setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
Enable or disable reads from the second-level cache.void
setCacheStoreMode(CacheStoreMode cacheStoreMode)
Enable or disable writes to the second-level cache.void
setDefaultReadOnly(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.void
setEnforcingFetchGraph(boolean isEnforcingFetchGraph)
Deprecated, for removal: This API element is subject to removal in a future version.void
setFlushMode(FlushModeType flushModeType)
Set the currentJPA flush mode
for this session.void
setProperty(String propertyName, Object value)
void
setReadOnly(Object entity, boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.boolean
shouldAutoClose()
Should this session be automatically closed after the current transaction completes?protected boolean
shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
void
startTransactionBoundary()
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA TransactionString
toString()
<T> T
unwrap(Class<T> clazz)
void
update(Object obj)
Deprecated.void
update(String entityName, Object object)
Deprecated.-
Methods inherited from class org.hibernate.internal.AbstractSharedSessionContract
accessTransaction, beginTransaction, buildNamedQuery, buildNamedQuery, checkMutationQuery, checkOpen, checkResultType, checkSelectionQuery, checkTransactionNeededForUpdateOperation, checkTransactionSynchStatus, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNamedSelectionQuery, createNamedSelectionQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQueryImplementor, createQuery, createQuery, createQuery, createQuery, createQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, createSqmQueryImplementor, doReturningWork, doWork, execute, generateEntityKey, getCacheMode, getCacheTransactionSynchronization, getConfiguredJdbcBatchSize, getCriteriaBuilder, getCurrentTransaction, getEntityNameResolver, getEventListenerManager, getExceptionConverter, getFactory, getFlushMode, getHibernateFlushMode, getInterceptor, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcCoordinator, getJdbcServices, getJdbcSessionContext, getJdbcTimeZone, getLobCreator, getNamedNativeQuery, getNamedNativeQuery, getNamedProcedureCall, getNamedQuery, getPreferredSqlTypeCodeForBoolean, getResultSetMappingMemento, getSessionIdentifier, getSessionToken, getTenantIdentifier, getTransaction, getTransactionCoordinator, getTransactionStartTimestamp, interpretHql, isClosed, isConnected, isCriteriaCopyTreeEnabled, isJoinedToTransaction, isOpenOrWaitingForAutoClose, isTransactionInProgress, joinTransaction, markForRollbackOnly, prepareForAutoClose, prepareForQueryExecution, setCacheMode, setClosed, setCriteriaCopyTreeEnabled, setHibernateFlushMode, setJdbcBatchSize, 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
getJdbcBatchSize, getJdbcConnectionAccess, getJdbcSessionContext, getTransactionCoordinator
-
Methods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
execute, fromContext
-
Methods inherited from interface org.hibernate.query.QueryProducer
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, getCacheMode, getFlushMode, getHibernateFlushMode, setCacheMode, setHibernateFlushMode
-
Methods inherited from interface org.hibernate.engine.spi.SessionImplementor
asSessionImplementor, isSessionImplementor
-
Methods inherited from interface org.hibernate.SharedSessionContract
beginTransaction, doReturningWork, doWork, getCriteriaBuilder, getJdbcBatchSize, getNamedProcedureCall, getTenantIdentifier, 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, getSessionIdentifier, getSessionToken, getTransactionStartTimestamp, getTypeConfiguration, isClosed, isCriteriaCopyTreeEnabled, isOpenOrWaitingForAutoClose, isStatelessSession, isTransactionInProgress, markForRollbackOnly, prepareForQueryExecution, setCacheMode, setCriteriaCopyTreeEnabled, setHibernateFlushMode
-
Methods inherited from interface org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options
shouldAutoJoinTransaction
-
Methods inherited from interface org.hibernate.type.descriptor.WrapperOptions
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:
applyQuerySettingsAndHints
in classAbstractSharedSessionContract
-
applyLockOptionsHint
protected void applyLockOptionsHint(SelectionQuery<?> query)
-
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(Query<?> query)
- Overrides:
applyQuerySettingsAndHints
in classAbstractSharedSessionContract
-
sessionWithOptions
public SharedSessionBuilder sessionWithOptions()
Description copied from interface:Session
Obtain aSession
builder with the ability to copy certain information from this session.- Specified by:
sessionWithOptions
in interfaceSession
- Returns:
- the session builder
-
clear
public void clear()
Description copied from interface:Session
Completely 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:
clear
in interfaceEntityManager
- Specified by:
clear
in interfaceSession
-
close
public void close() throws HibernateException
Description copied from interface:SharedSessionContract
End the session by releasing the JDBC connection and cleaning up.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceEntityManager
- Specified by:
close
in interfaceSharedSessionContract
- Overrides:
close
in classAbstractSharedSessionContract
- Throws:
HibernateException
- Indicates problems cleaning up.
-
closeWithoutOpenChecks
public void closeWithoutOpenChecks() throws HibernateException
- Throws:
HibernateException
-
shouldCloseJdbcCoordinatorOnClose
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
- Overrides:
shouldCloseJdbcCoordinatorOnClose
in classAbstractSharedSessionContract
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()
Description copied from interface:SharedSessionContractImplementor
Is auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabled
in interfaceSharedSessionContractImplementor
- See Also:
AvailableSettings.AUTO_CLOSE_SESSION
,SessionFactoryOptions.isAutoCloseSessionEnabled()
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContract
Check if the session is still open.- Specified by:
isOpen
in interfaceEntityManager
- Specified by:
isOpen
in interfaceSharedSessionContract
- Overrides:
isOpen
in classAbstractSharedSessionContract
- Returns:
- boolean
-
checkSessionFactoryOpen
protected void checkSessionFactoryOpen()
-
shouldAutoClose
public boolean shouldAutoClose()
Description copied from interface:SharedSessionContractImplementor
Should this session be automatically closed after the current transaction completes?- Specified by:
shouldAutoClose
in interfaceSharedSessionContractImplementor
-
setAutoClear
public void setAutoClear(boolean enabled)
Description copied from interface:SharedSessionContractImplementor
Enable or disable automatic cache clearing from after transaction completion.- Specified by:
setAutoClear
in interfaceSharedSessionContractImplementor
-
afterOperation
public void afterOperation(boolean success)
Description copied from interface:SharedSessionContractImplementor
Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.- Specified by:
afterOperation
in interfaceLoadAccessContext
- Specified by:
afterOperation
in interfaceSharedSessionContractImplementor
- Parameters:
success
-true
if the operation a success
-
addEventListeners
public void addEventListeners(SessionEventListener... listeners)
Description copied from interface:Session
Add one or more listeners to the Session- Specified by:
addEventListeners
in 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:
cleanupOnClose
in classAbstractSharedSessionContract
-
getCurrentLockMode
public LockMode getCurrentLockMode(Object object) throws HibernateException
Description copied from interface:Session
Determine the currentLockMode
of the given managed instance associated with this session.- Specified by:
getCurrentLockMode
in interfaceSession
- Parameters:
object
- a persistent instance- Returns:
- the current lock mode
- Throws:
HibernateException
-
getEntityUsingInterceptor
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.- Specified by:
getEntityUsingInterceptor
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
checkNoUnresolvedActionsBeforeOperation
protected void checkNoUnresolvedActionsBeforeOperation()
-
checkNoUnresolvedActionsAfterOperation
protected void checkNoUnresolvedActionsAfterOperation()
-
delayedAfterCompletion
public void delayedAfterCompletion()
- Specified by:
delayedAfterCompletion
in interfaceLoadAccessContext
- Overrides:
delayedAfterCompletion
in classAbstractSharedSessionContract
-
pulseTransactionCoordinator
public void pulseTransactionCoordinator()
Description copied from interface:LoadAccessContext
Callback to pulse the transaction coo- Specified by:
pulseTransactionCoordinator
in interfaceLoadAccessContext
- Overrides:
pulseTransactionCoordinator
in classAbstractSharedSessionContract
-
checkOpenOrWaitingForAutoClose
public void checkOpenOrWaitingForAutoClose()
Description copied from interface:LoadAccessContext
Callback to check whether the session is "active"- Specified by:
checkOpenOrWaitingForAutoClose
in interfaceLoadAccessContext
- Overrides:
checkOpenOrWaitingForAutoClose
in classAbstractSharedSessionContract
-
saveOrUpdate
@Deprecated public void saveOrUpdate(Object object) throws HibernateException
Deprecated.Description copied from interface:Session
EitherSession.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:
saveOrUpdate
in 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
@Deprecated public void saveOrUpdate(String entityName, Object obj) throws HibernateException
Deprecated.Description copied from interface:Session
EitherSession.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:
saveOrUpdate
in 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
@Deprecated public Object save(Object obj) throws HibernateException
Deprecated.Description copied from interface:Session
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassigned
generator 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:
save
in interfaceSession
- Parameters:
obj
- a transient instance of a persistent class- Returns:
- the generated identifier
- Throws:
HibernateException
-
save
@Deprecated public Object save(String entityName, Object object) throws HibernateException
Deprecated.Description copied from interface:Session
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassigned
generator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE
.- Specified by:
save
in interfaceSession
- Parameters:
entityName
- the entity nameobject
- a transient instance of a persistent class- Returns:
- the generated identifier
- Throws:
HibernateException
-
update
@Deprecated public void update(Object obj) throws HibernateException
Deprecated.Description copied from interface:Session
Update 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:
update
in interfaceSession
- Parameters:
obj
- a detached instance containing updated state- Throws:
HibernateException
-
update
@Deprecated public void update(String entityName, Object object) throws HibernateException
Deprecated.Description copied from interface:Session
Update 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:
update
in 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:Session
Obtain 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:SessionImplementor
Cascade the lock operation to the given child entity.- Specified by:
lock
in interfaceSessionImplementor
-
lock
public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException
Description copied from interface:Session
Obtain 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:
lock
in interfaceSession
- Parameters:
entityName
- the name of the entityobject
- a persistent or transient instancelockMode
- the lock level- Throws:
HibernateException
- perform a version check with
-
buildLockRequest
@Deprecated public Session.LockRequest buildLockRequest(LockOptions lockOptions)
Deprecated.Description copied from interface:Session
Build a newlock request
that specifies:- the
LockMode
to use, - the pessimistic lock timeout, and
- the scope that is, whether the lock extends to rows of owned collections.
Timeout and scope are ignored if the specified
LockMode
represents a flavor of optimistic locking.Call
Session.LockRequest.lock(Object)
to actually obtain the requested lock on a managed entity instance.- Specified by:
buildLockRequest
in interfaceSession
- Parameters:
lockOptions
- contains the lock level- Returns:
- a
Session.LockRequest
that can be used to lock any given object.
- the
-
lock
public void lock(Object object, LockMode lockMode) throws HibernateException
Description copied from interface:Session
Obtain 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:
lock
in interfaceSession
- Parameters:
object
- a persistent or transient instancelockMode
- the lock level- Throws:
HibernateException
- perform a version check with
-
persist
public void persist(String entityName, Object object) throws HibernateException
Description copied from interface:Session
Make a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST
.For entities with a
generated id
,persist()
ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.- Specified by:
persist
in interfaceSession
- Parameters:
entityName
- the entity nameobject
- a transient instance to be made persistent- Throws:
HibernateException
-
persist
public void persist(Object object) throws HibernateException
Description copied from interface:Session
Make a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST
.For entities with a
generated id
,persist()
ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.- Specified by:
persist
in interfaceEntityManager
- Specified by:
persist
in interfaceSession
- Parameters:
object
- a transient instance to be made persistent- Throws:
HibernateException
-
persist
public void persist(String entityName, Object object, PersistContext copiedAlready) throws HibernateException
Description copied from interface:EventSource
Cascade persist an entity instance- Specified by:
persist
in interfaceEventSource
- Specified by:
persist
in interfaceSessionImplementor
- Throws:
HibernateException
-
persistOnFlush
public void persistOnFlush(String entityName, Object object, PersistContext copiedAlready)
Description copied from interface:EventSource
Cascade persist an entity instance during the flush process- Specified by:
persistOnFlush
in interfaceEventSource
- Specified by:
persistOnFlush
in interfaceSessionImplementor
-
merge
public <T> T merge(String entityName, T object) throws HibernateException
Description copied from interface:Session
Copy 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:
merge
in 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) throws HibernateException
Description copied from interface:Session
Copy 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:
merge
in interfaceEntityManager
- Specified by:
merge
in interfaceSession
- Parameters:
object
- a detached instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
merge
public void merge(String entityName, Object object, MergeContext copiedAlready) throws HibernateException
Description copied from interface:EventSource
Cascade merge an entity instance- Specified by:
merge
in interfaceEventSource
- Specified by:
merge
in interfaceSessionImplementor
- Throws:
HibernateException
-
delete
@Deprecated public void delete(Object object) throws HibernateException
Deprecated.Description copied from interface:Session
Remove a persistent instance from the datastore. The argument may be an instance associated with the receivingSession
or 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:
delete
in interfaceSession
- Parameters:
object
- the instance to be removed- Throws:
HibernateException
-
delete
@Deprecated public void delete(String entityName, Object object) throws HibernateException
Deprecated.Description copied from interface:Session
Remove a persistent instance from the datastore. The second argument may be an instance associated with the receivingSession
or 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:
delete
in 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) throws HibernateException
Description copied from interface:EventSource
Cascade delete an entity instance- Specified by:
delete
in interfaceEventSource
- Specified by:
delete
in interfaceSessionImplementor
- Throws:
HibernateException
-
removeOrphanBeforeUpdates
public void removeOrphanBeforeUpdates(String entityName, Object child)
Description copied from interface:EventSource
A specialized type of deletion for orphan removal that must occur prior to queued inserts and updates.- Specified by:
removeOrphanBeforeUpdates
in interfaceEventSource
- Specified by:
removeOrphanBeforeUpdates
in interfaceSessionImplementor
-
load
public void load(Object object, Object id) throws HibernateException
Description copied from interface:Session
Read the persistent state associated with the given identifier into the given transient instance.- Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
@Deprecated public <T> T load(Class<T> entityClass, Object id) throws HibernateException
Deprecated.Description copied from interface:Session
Return 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:
load
in interfaceSession
- Parameters:
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the class- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
@Deprecated public Object load(String entityName, Object id) throws HibernateException
Deprecated.Description copied from interface:Session
Return 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:
load
in interfaceSession
- Specified by:
load
in 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) throws HibernateException
Description copied from interface:Session
Return 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)
.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.IGNORE
before calling this method.
- Specified by:
get
in 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) throws HibernateException
Description copied from interface:Session
Return 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:
get
in interfaceSession
- Parameters:
entityName
- the entity nameid
- an identifier- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
immediateLoad
public Object immediateLoad(String entityName, Object id) throws HibernateException
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:
immediateLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable)
Description copied from interface:SharedSessionContractImplementor
Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.- When
nullable = false
, this method may create a new proxy or return an existing proxy; if it does not exist, an exception is thrown. - When
nullable = true
, the method does not create new proxies, though it might return an existing proxy; if it does not exist, anull
value is returned.
When
eager = true
, the object is eagerly fetched from the database.- Specified by:
internalLoad
in interfaceSharedSessionContractImplementor
- When
-
internalLoadType
protected static LoadEventListener.LoadType internalLoadType(boolean eager, boolean nullable)
-
load
@Deprecated public <T> T load(Class<T> entityClass, Object id, LockMode lockMode) throws HibernateException
Deprecated.Description copied from interface:Session
Return 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:
load
in 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
@Deprecated public <T> T load(Class<T> entityClass, Object id, LockOptions lockOptions) throws HibernateException
Deprecated.Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
load
in interfaceSession
- Parameters:
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockOptions
- contains the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
@Deprecated public Object load(String entityName, Object id, LockMode lockMode) throws HibernateException
Deprecated.Description copied from interface:Session
Return 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:
load
in 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
@Deprecated public Object load(String entityName, Object id, LockOptions lockOptions) throws HibernateException
Deprecated.Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
load
in 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) throws HibernateException
Description copied from interface:Session
Return 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:
get
in 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) throws HibernateException
Description copied from interface:Session
Return 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:
get
in 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) throws HibernateException
Description copied from interface:Session
Return 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:
get
in 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) throws HibernateException
Description copied from interface:Session
Return 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:
get
in 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:Session
Create anIdentifierLoadAccess
instance to retrieve the specified entity type by primary key.
-
byId
public <T> IdentifierLoadAccessImpl<T> byId(Class<T> entityClass)
Description copied from interface:Session
Create anIdentifierLoadAccess
instance to retrieve the specified entity by primary key.
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIds
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by primary key values
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(String entityName)
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIds
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by primary key values
-
byNaturalId
public <T> NaturalIdLoadAccess<T> byNaturalId(String entityName)
Description copied from interface:Session
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.- Specified by:
byNaturalId
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
byNaturalId
public <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
Description copied from interface:Session
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.- Specified by:
byNaturalId
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
bySimpleNaturalId
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(String entityName)
Description copied from interface:Session
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by itsnatural id
.- Specified by:
bySimpleNaturalId
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
bySimpleNaturalId
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
Description copied from interface:Session
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by its simple (single attribute)natural id
.- Specified by:
bySimpleNaturalId
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
byMultipleNaturalId
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(Class<T> entityClass)
Description copied from interface:Session
Access to load multiple entities bynatural id
.- Specified by:
byMultipleNaturalId
in interfaceSession
-
byMultipleNaturalId
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(String entityName)
Description copied from interface:Session
Access to load multiple entities bynatural id
.- Specified by:
byMultipleNaturalId
in interfaceSession
-
fireLoad
public void fireLoad(LoadEvent event, LoadEventListener.LoadType loadType)
- Specified by:
fireLoad
in interfaceLoadAccessContext
-
refresh
public void refresh(Object object) throws HibernateException
Description copied from interface:Session
Reread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update
- after executing any HQL update or delete statement
- after executing a native SQL statement
- after inserting a
Blob
orClob
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:
refresh
in interfaceEntityManager
- Specified by:
refresh
in interfaceSession
- Parameters:
object
- a persistent or detached instance- Throws:
HibernateException
-
refresh
@Deprecated public void refresh(String entityName, Object object) throws HibernateException
Deprecated.Description copied from interface:Session
Reread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update
- after executing any HQL update or delete statement
- after executing a native SQL statement
- after inserting a
Blob
orClob
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH
.- Specified by:
refresh
in interfaceSession
- Parameters:
entityName
- the name of the entityobject
- a persistent or detached instance- Throws:
HibernateException
-
refresh
public void refresh(Object object, LockMode lockMode) throws HibernateException
Description copied from interface:Session
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.Convenient form of
Session.refresh(Object, LockOptions)
- Specified by:
refresh
in interfaceSession
- Parameters:
object
- a persistent or detached instancelockMode
- the lock mode to use- Throws:
HibernateException
- See Also:
Session.refresh(Object, LockOptions)
-
refresh
public void refresh(Object object, LockOptions lockOptions) throws HibernateException
Description copied from interface:Session
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.- Specified by:
refresh
in interfaceSession
- Parameters:
object
- a persistent or detached instancelockOptions
- contains the lock mode to use- Throws:
HibernateException
-
refresh
@Deprecated public void refresh(String entityName, Object object, LockOptions lockOptions) throws HibernateException
Deprecated.Description copied from interface:Session
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.- Specified by:
refresh
in interfaceSession
- Parameters:
entityName
- the name of the entityobject
- a persistent or detached instancelockOptions
- contains the lock mode to use- Throws:
HibernateException
-
refresh
public void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException
Description copied from interface:EventSource
Cascade refresh an entity instance- Specified by:
refresh
in interfaceEventSource
- Specified by:
refresh
in interfaceSessionImplementor
- Throws:
HibernateException
-
replicate
public void replicate(Object obj, ReplicationMode replicationMode) throws HibernateException
Description copied from interface:Session
Persist 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:
replicate
in interfaceSession
- Parameters:
obj
- a detached instance of a persistent classreplicationMode
- the replication mode to use- Throws:
HibernateException
-
replicate
public void replicate(String entityName, Object obj, ReplicationMode replicationMode) throws HibernateException
Description copied from interface:Session
Persist 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:
replicate
in 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) throws HibernateException
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:
evict
in interfaceSession
- Parameters:
object
- the managed entity to evict- Throws:
HibernateException
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequired
in interfaceSharedSessionContractImplementor
- Parameters:
querySpaces
- the tables named in the query.- Returns:
- true if flush is required, false otherwise.
- Throws:
HibernateException
-
isDirty
public boolean isDirty() throws HibernateException
Description copied from interface:Session
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?- Specified by:
isDirty
in interfaceSession
- Returns:
true
if the session contains pending changes;false
otherwise.- Throws:
HibernateException
- could not perform dirtying checking
-
flush
public void flush() throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Flush this session.- Specified by:
flush
in interfaceEntityManager
- Specified by:
flush
in interfaceSession
- Specified by:
flush
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
- if changes could not be synchronized with the database
-
setFlushMode
public void setFlushMode(FlushModeType flushModeType)
Description copied from interface:Session
Set the currentJPA flush mode
for 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:
setFlushMode
in interfaceEntityManager
- Specified by:
setFlushMode
in interfaceSession
- Parameters:
flushModeType
- the newFlushModeType
- See Also:
for additional options
-
forceFlush
public void forceFlush(EntityEntry entityEntry) throws HibernateException
Description copied from interface:SessionImplementor
Initiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlush
in interfaceEventSource
- Specified by:
forceFlush
in interfaceSessionImplementor
- Throws:
HibernateException
-
forceFlush
public void forceFlush(EntityKey key) throws HibernateException
Description copied from interface:SessionImplementor
Initiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlush
in interfaceEventSource
- Specified by:
forceFlush
in interfaceSessionImplementor
- Throws:
HibernateException
-
instantiate
public Object instantiate(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Instantiate the entity class, initializing with the given identifier.- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
instantiate
public Object instantiate(EntityPersister persister, Object id) throws HibernateException
give the interceptor an opportunity to override the default instantiation- Specified by:
instantiate
in interfaceEventSource
- Specified by:
instantiate
in interfaceSessionImplementor
- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getEntityPersister
public EntityPersister getEntityPersister(String entityName, Object object)
Description copied from interface:SharedSessionContractImplementor
Get theEntityPersister
for the given entity instance.- Specified by:
getEntityPersister
in interfaceSharedSessionContractImplementor
- Parameters:
entityName
- optional entity nameobject
- the entity instance
-
getIdentifier
public Object getIdentifier(Object object) throws HibernateException
Description copied from interface:Session
Return 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:
getIdentifier
in 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:
getContextEntityIdentifier
in interfaceSharedSessionContractImplementor
-
contains
public boolean contains(Object object)
- Specified by:
contains
in interfaceEntityManager
-
contains
public boolean contains(String entityName, Object object)
Description copied from interface:Session
Determine if the given entity is associated with this session.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Overrides:
createStoredProcedureCall
in 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:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Overrides:
createStoredProcedureCall
in 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:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Overrides:
createStoredProcedureCall
in 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:SharedSessionContractImplementor
Obtain the factory which created this session.- Specified by:
getSessionFactory
in interfaceSession
- Specified by:
getSessionFactory
in interfaceSessionImplementor
- Specified by:
getSessionFactory
in interfaceSharedSessionContractImplementor
- Specified by:
getSessionFactory
in interfaceWrapperOptions
- Returns:
- the session factory
- See Also:
SessionFactory
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing)
Description copied from interface:SharedSessionContractImplementor
Initialize the given collection (if not already initialized).- Specified by:
initializeCollection
in interfaceSharedSessionContractImplementor
-
bestGuessEntityName
public String bestGuessEntityName(Object object)
Description copied from interface:SharedSessionContractImplementor
Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.- Specified by:
bestGuessEntityName
in interfaceSharedSessionContractImplementor
-
bestGuessEntityName
public String bestGuessEntityName(Object object, EntityEntry entry)
Description copied from interface:SharedSessionContractImplementor
Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.- Specified by:
bestGuessEntityName
in interfaceSharedSessionContractImplementor
-
getEntityName
public String getEntityName(Object object)
Description copied from interface:Session
Return the entity name for a persistent entity.- Specified by:
getEntityName
in 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:Session
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. 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:
getReference
in interfaceSession
- Parameters:
object
- a detached persistent instance- Returns:
- the persistent instance or proxy
-
guessEntityName
public String guessEntityName(Object object) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.- Specified by:
guessEntityName
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
cancelQuery
public void cancelQuery() throws HibernateException
Description copied from interface:Session
Cancel the execution of the current query.This is the sole method on session which may be safely called from another thread.
- Specified by:
cancelQuery
in interfaceSession
- Throws:
HibernateException
- if there was a problem cancelling the query
-
getActionQueue
public ActionQueue getActionQueue()
Description copied from interface:SessionImplementor
Get theActionQueue
associated with this session.- Specified by:
getActionQueue
in interfaceEventSource
- Specified by:
getActionQueue
in interfaceSessionImplementor
-
getPersistenceContext
public PersistenceContext getPersistenceContext()
Description copied from interface:SharedSessionContractImplementor
Get the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()
for a faster alternative.- Specified by:
getPersistenceContext
in interfaceSharedSessionContractImplementor
-
getPersistenceContextInternal
public PersistenceContext getPersistenceContextInternal()
Description copied from interface:SharedSessionContractImplementor
Similar toSharedSessionContractImplementor.getPersistenceContext()
, with two differences:- this version performs better as it allows for inlining and probably better prediction, and
- it skips some checks of the current state of the session.
- Specified by:
getPersistenceContextInternal
in interfaceSharedSessionContractImplementor
- Returns:
- the
PersistenceContext
associated to this session.
-
getStatistics
public SessionStatistics getStatistics()
Description copied from interface:Session
Get the statistics for this session.- Specified by:
getStatistics
in interfaceSession
- Returns:
- the session statistics being collected for this session
-
isEventSource
public boolean isEventSource()
Description copied from interface:SharedSessionContractImplementor
Determines if this session implementsEventSource
.Only stateful session are sources of events. If this object is a stateless session, this method return
false
.- Specified by:
isEventSource
in interfaceSharedSessionContractImplementor
-
asEventSource
public EventSource asEventSource()
Description copied from interface:SharedSessionContractImplementor
Cast this session toEventSource
if possible.Only stateful session are sources of events. If this object is a stateless session, this method throws.
- Specified by:
asEventSource
in interfaceSharedSessionContractImplementor
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SharedSessionContractImplementor
Are entities and proxies loaded by this session read-only by default?- Specified by:
isDefaultReadOnly
in interfaceSession
- Specified by:
isDefaultReadOnly
in 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:Session
Change 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
Query
useQuery.setReadOnly(boolean)
.- Specified by:
setDefaultReadOnly
in 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:Session
Is 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:
isReadOnly
in interfaceSession
- Parameters:
entityOrProxy
- an entity or proxy- Returns:
true
if the entity or proxy is read-only,false
if the entity or proxy is modifiable.- See Also:
Session.isDefaultReadOnly()
-
setReadOnly
public void setReadOnly(Object entity, boolean readOnly)
Description copied from interface:Session
Set 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
Query
useQuery.setReadOnly(boolean)
- Specified by:
setReadOnly
in interfaceSession
- Parameters:
entity
- an entity or proxyreadOnly
-true
if the entity or proxy should be made read-only;false
if the entity or proxy should be made modifiable- See Also:
Session.setDefaultReadOnly(boolean)
,Query.setReadOnly(boolean)
-
getCacheStoreMode
public CacheStoreMode getCacheStoreMode()
Description copied from interface:Session
The JPA-definedCacheStoreMode
.- Specified by:
getCacheStoreMode
in interfaceSession
- See Also:
Session.getCacheMode()
-
getCacheRetrieveMode
public CacheRetrieveMode getCacheRetrieveMode()
Description copied from interface:Session
The JPA-definedCacheRetrieveMode
.- Specified by:
getCacheRetrieveMode
in interfaceSession
- See Also:
Session.getCacheMode()
-
setCacheStoreMode
public void setCacheStoreMode(CacheStoreMode cacheStoreMode)
Description copied from interface:Session
Enable or disable writes to the second-level cache.- Specified by:
setCacheStoreMode
in interfaceSession
- Parameters:
cacheStoreMode
- a JPA-definedCacheStoreMode
- See Also:
Session.setCacheMode(CacheMode)
-
setCacheRetrieveMode
public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
Description copied from interface:Session
Enable or disable reads from the second-level cache.- Specified by:
setCacheRetrieveMode
in interfaceSession
- Parameters:
cacheRetrieveMode
- a JPA-definedCacheRetrieveMode
- See Also:
Session.setCacheMode(CacheMode)
-
afterScrollOperation
public void afterScrollOperation()
Description copied from interface:SharedSessionContractImplementor
Called after each operation on aScrollableResults
, providing an opportunity for a stateless session to clear its temporary persistence context. For a stateful session, this method does nothing.- Specified by:
afterScrollOperation
in interfaceSharedSessionContractImplementor
-
getLoadQueryInfluencers
public LoadQueryInfluencers getLoadQueryInfluencers()
Description copied from interface:SharedSessionContractImplementor
Get theLoadQueryInfluencers
associated with this session.- Specified by:
getLoadQueryInfluencers
in interfaceSharedSessionContractImplementor
- Returns:
- the
LoadQueryInfluencers
associated with this session; should never be null.
-
getEnabledFilter
public Filter getEnabledFilter(String filterName)
Description copied from interface:Session
Retrieve a currently enabled filter by name.- Specified by:
getEnabledFilter
in interfaceSession
- Parameters:
filterName
- the name of the filter to be retrieved.- Returns:
- the
Filter
instance representing the enabled filter.
-
enableFilter
public Filter enableFilter(String filterName)
Description copied from interface:Session
Enable the named filter for this current session.The returned
Filter
object must be used to bind arguments to parameters of the filter, and every parameter must be set before any other operation of this session is called.- Specified by:
enableFilter
in interfaceSession
- Parameters:
filterName
- the name of the filter to be enabled.- Returns:
- the
Filter
instance representing the enabled filter. - See Also:
FilterDef
-
disableFilter
public void disableFilter(String filterName)
Description copied from interface:Session
Disable the named filter for the current session.- Specified by:
disableFilter
in interfaceSession
- Parameters:
filterName
- the name of the filter to be disabled.
-
isFetchProfileEnabled
public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
Description copied from interface:Session
Is thefetch profile
with the given name enabled in this session?- Specified by:
isFetchProfileEnabled
in 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) throws UnknownProfileException
Description copied from interface:Session
Enable thefetch profile
with the given name in this session. If the requested fetch profile is already enabled, the call has no effect.- Specified by:
enableFetchProfile
in 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) throws UnknownProfileException
Description copied from interface:Session
Disable thefetch profile
with the given name in this session. If the requested fetch profile is not currently enabled, the call has no effect.- Specified by:
disableFetchProfile
in 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
-
getLobHelper
public LobHelper getLobHelper()
Description copied from interface:Session
- Specified by:
getLobHelper
in interfaceSession
- Returns:
- an instance of
LobHelper
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:JdbcSessionOwner
A before-completion callback to the owner.- Specified by:
beforeTransactionCompletion
in interfaceJdbcSessionOwner
- Overrides:
beforeTransactionCompletion
in classAbstractSharedSessionContract
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed)
Description copied from interface:JdbcSessionOwner
An after-completion callback to the owner.- Specified by:
afterTransactionCompletion
in interfaceJdbcSessionOwner
- Overrides:
afterTransactionCompletion
in 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:
addSharedSessionTransactionObserver
in classAbstractSharedSessionContract
-
removeSharedSessionTransactionObserver
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
- Overrides:
removeSharedSessionTransactionObserver
in classAbstractSharedSessionContract
-
startTransactionBoundary
public void startTransactionBoundary()
Description copied from interface:JdbcSessionOwner
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction- Specified by:
startTransactionBoundary
in interfaceJdbcSessionOwner
- Overrides:
startTransactionBoundary
in classAbstractSharedSessionContract
-
afterTransactionBegin
public void afterTransactionBegin()
Description copied from interface:JdbcSessionOwner
A after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBegin
in interfaceJdbcSessionOwner
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()
- Specified by:
flushBeforeTransactionCompletion
in interfaceJdbcSessionOwner
-
getSession
public SessionImplementor getSession()
Description copied from interface:SharedSessionContractImplementor
Returns this object, fulfilling the contract ofWrapperOptions
.- Specified by:
getSession
in interfaceLoadAccessContext
- Specified by:
getSession
in interfaceSessionImplementor
- Specified by:
getSession
in interfaceSharedSessionContractImplementor
- Specified by:
getSession
in interfaceWrapperOptions
-
remove
public void remove(Object entity)
Description copied from interface:Session
Mark 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:
remove
in interfaceEntityManager
- Specified by:
remove
in interfaceSession
- Parameters:
entity
- the managed persistent instance to remove
-
find
public <T> T find(Class<T> entityClass, Object primaryKey)
- Specified by:
find
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
- Specified by:
find
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType)
- Specified by:
find
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String,Object> properties)
- Specified by:
find
in interfaceEntityManager
-
determineAppropriateLocalCacheMode
protected CacheMode determineAppropriateLocalCacheMode(Map<String,Object> localProperties)
-
getReference
public <T> T getReference(Class<T> entityClass, Object id)
Description copied from interface:Session
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. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.Note that
Hibernate.createDetachedProxy(SessionFactory, Class, Object)
may be used to obtain a detached reference.- Specified by:
getReference
in interfaceEntityManager
- Specified by:
getReference
in 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:Session
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. 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:
getReference
in 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:
lock
in interfaceEntityManager
-
lock
public void lock(Object entity, LockModeType lockModeType, Map<String,Object> properties)
- Specified by:
lock
in interfaceEntityManager
-
refresh
public void refresh(Object entity, Map<String,Object> properties)
- Specified by:
refresh
in interfaceEntityManager
-
refresh
public void refresh(Object entity, LockModeType lockModeType)
- Specified by:
refresh
in interfaceEntityManager
-
refresh
public void refresh(Object entity, LockModeType lockModeType, Map<String,Object> properties)
- Specified by:
refresh
in interfaceEntityManager
-
detach
public void detach(Object entity)
Description copied from interface:Session
Remove 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:
detach
in interfaceEntityManager
- Specified by:
detach
in interfaceSession
- Parameters:
entity
- the managed instance to detach
-
getLockMode
public LockModeType getLockMode(Object entity)
- Specified by:
getLockMode
in interfaceEntityManager
-
setProperty
public void setProperty(String propertyName, Object value)
- Specified by:
setProperty
in interfaceEntityManager
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getProperties
in interfaceEntityManager
-
createNamedStoredProcedureQuery
public ProcedureCall createNamedStoredProcedureQuery(String name)
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
createNamedStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createNamedStoredProcedureQuery
in interfaceSharedSessionContract
- Overrides:
createNamedStoredProcedureQuery
in 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:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Overrides:
createStoredProcedureQuery
in 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:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Overrides:
createStoredProcedureQuery
in 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:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Overrides:
createStoredProcedureQuery
in 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:
unwrap
in interfaceEntityManager
-
getDelegate
public Object getDelegate()
- Specified by:
getDelegate
in interfaceEntityManager
-
getEntityManagerFactory
public SessionFactoryImplementor getEntityManagerFactory()
- Specified by:
getEntityManagerFactory
in interfaceEntityManager
-
getMetamodel
public Metamodel getMetamodel()
- Specified by:
getMetamodel
in interfaceEntityManager
-
createEntityGraph
public <T> RootGraphImplementor<T> createEntityGraph(Class<T> rootType)
- Specified by:
createEntityGraph
in interfaceEntityManager
- Specified by:
createEntityGraph
in interfaceSession
- Specified by:
createEntityGraph
in interfaceSessionImplementor
-
createEntityGraph
public RootGraphImplementor<?> createEntityGraph(String graphName)
- Specified by:
createEntityGraph
in interfaceEntityManager
- Specified by:
createEntityGraph
in interfaceSession
- Specified by:
createEntityGraph
in interfaceSessionImplementor
-
getEntityGraph
public RootGraphImplementor<?> getEntityGraph(String graphName)
- Specified by:
getEntityGraph
in interfaceEntityManager
- Specified by:
getEntityGraph
in interfaceSession
- Specified by:
getEntityGraph
in interfaceSessionImplementor
-
getEntityGraphs
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
- Specified by:
getEntityGraphs
in interfaceEntityManager
- Specified by:
getEntityGraphs
in interfaceSession
-
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:SharedSessionContractImplementor
Are we currently enforcing a fetch graph?- Specified by:
isEnforcingFetchGraph
in 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:SharedSessionContractImplementor
Enable or disable fetch graph enforcement.- Specified by:
setEnforcingFetchGraph
in interfaceSharedSessionContractImplementor
-
-