Class StatelessSessionImpl
- java.lang.Object
-
- org.hibernate.internal.AbstractSharedSessionContract
-
- org.hibernate.internal.StatelessSessionImpl
-
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,LobCreationContext,SharedSessionContractImplementor,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,SharedSessionContract,StatelessSession,JavaType.CoercionContext,WrapperOptions
public class StatelessSessionImpl extends AbstractSharedSessionContract implements StatelessSession
Concrete implementation of theStatelessSessionAPI.Exposes two interfaces:
StatelessSessionto the application, andSharedSessionContractImplementor(an SPI interface) 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>
-
-
Field Summary
-
Fields inherited from class org.hibernate.internal.AbstractSharedSessionContract
closed, fastSessionServices, waitingForAutoClose
-
-
Constructor Summary
Constructors Constructor Description StatelessSessionImpl(SessionFactoryImpl factory, SessionCreationOptions options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterOperation(boolean success)Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.voidafterScrollOperation()Called after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context.voidafterTransactionBegin()A after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed)An after-completion callback to the owner.StatelessSessionasStatelessSession()Cast this object toStatelessSession, if possible.booleanautoFlushIfRequired(Set<String> querySpaces)detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushvoidbeforeTransactionCompletion()A before-completion callback to the owner.StringbestGuessEntityName(Object object)Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.voiddelete(Object entity)Delete a record.voiddelete(String entityName, Object entity)Delete a record.voidfetch(Object association)Fetch an association or collection that's configured for lazy loading.voidflush()Flush this session.voidflushBeforeTransactionCompletion()<T> Tget(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id)Retrieve a record, fetching associations specified by the givenEntityGraph.<T> Tget(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id, LockMode lockMode)Retrieve a record, fetching associations specified by the givenEntityGraph, and obtaining the specified lock mode.<T> Tget(Class<T> entityClass, Object id)Retrieve a record.<T> Tget(Class<T> entityClass, Object id, LockMode lockMode)Retrieve a record, obtaining the specified lock mode.Objectget(String entityName, Object id)Retrieve a record.Objectget(String entityName, Object id, LockMode lockMode)Retrieve a record, obtaining the specified lock mode.CacheModegetCacheMode()Get the currentCacheModefor this session.ObjectgetContextEntityIdentifier(Object object)Return the identifier of the persistent object, or null if it is not associated with this session.EntityPersistergetEntityPersister(String entityName, Object object)Get theEntityPersisterfor the given entity instance.ObjectgetEntityUsingInterceptor(EntityKey key)Get the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.ObjectgetIdentifier(Object entity)Return the identifier value of the given entity, which may be detached.LoadQueryInfluencersgetLoadQueryInfluencers()Get theLoadQueryInfluencersassociated with this session.PersistenceContextgetPersistenceContext()Get the persistence context for this session.PersistenceContextgetPersistenceContextInternal()Similar toSharedSessionContractImplementor.getPersistenceContext(), with two differences: this version performs better as it allows for inlining and probably better prediction, and it skips some checks of the current state of the session.StringguessEntityName(Object entity)Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.ObjectimmediateLoad(String entityName, Object id)Load an instance immediately.voidinitializeCollection(PersistentCollection<?> collection, boolean writing)Initialize the given collection (if not already initialized).Objectinsert(Object entity)Insert a record.Objectinsert(String entityName, Object entity)Insert a record.Objectinstantiate(String entityName, Object id)Instantiate the entity class, initializing with the given identifier.Objectinstantiate(EntityPersister persister, Object id)Instantiate the entity class of the givenEntityPersister, initializing the new instance with the given identifier.ObjectinternalLoad(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.booleanisAutoCloseSessionEnabled()Is auto-close at transaction completion enabled?booleanisDefaultReadOnly()Are entities and proxies loaded by this session read-only by default?booleanisStatelessSession()Does this object implementStatelessSession?booleanisTransactionInProgress()Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?protected Objectload(String entityName, Object identifier)voidrefresh(Object entity)Refresh the entity instance state from the database.voidrefresh(Object entity, LockMode lockMode)Refresh the entity instance state from the database.voidrefresh(String entityName, Object entity)Refresh the entity instance state from the database.voidrefresh(String entityName, Object entity, LockMode lockMode)Refresh the entity instance state from the database.voidsetAutoClear(boolean enabled)Enable or disable automatic cache clearing from after transaction completion.voidsetCacheMode(CacheMode cm)Set the currentCacheModefor this session.voidsetDefaultReadOnly(boolean readOnly)voidsetHibernateFlushMode(FlushMode flushMode)Set the currentFlushModefor this session.booleanshouldAutoClose()Should this session be automatically closed after the current transaction completes?booleanshouldAutoJoinTransaction()Indicates whether an active transaction should be automatically joined.voidupdate(Object entity)Update a record.voidupdate(String entityName, Object entity)Update a record.voidupsert(Object entity)Use a SQLmerge intostatement to perform an upsert, that is, to insert the record if it does not exist, or update it if it already exists.voidupsert(String entityName, Object entity)Use a SQLmerge intostatement to perform an upsert.-
Methods inherited from class org.hibernate.internal.AbstractSharedSessionContract
accessTransaction, addResultType, addSharedSessionTransactionObserver, applyQuerySettingsAndHints, applyQuerySettingsAndHints, beginTransaction, buildNamedQuery, buildNamedQuery, checkMutationQuery, checkOpen, checkOpenOrWaitingForAutoClose, checkResultType, checkSelectionQuery, checkTransactionNeededForUpdateOperation, checkTransactionSynchStatus, cleanupOnClose, close, createEntityGraph, createEntityGraph, createEntityGraph, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNamedSelectionQuery, createNamedSelectionQuery, createNamedStoredProcedureQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQueryImplementor, createNativeQueryImplementor, createQuery, createQuery, createQuery, createQuery, createQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, createSqmQueryImplementor, createSqmQueryImplementor, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, delayedAfterCompletion, disableFilter, doReturningWork, doWork, enableFilter, execute, generateEntityKey, getCacheTransactionSynchronization, getConfiguredJdbcBatchSize, getCriteriaBuilder, getCurrentTransaction, getEnabledFilter, getEntityGraph, getEntityGraphs, getEntityNameResolver, getEventListenerManager, getEventManager, getExceptionConverter, getFactory, getFlushMode, getHibernateFlushMode, getInterceptor, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcCoordinator, getJdbcServices, getJdbcSessionContext, getJdbcTimeZone, getLobCreator, getNamedNativeQuery, getNamedNativeQuery, getNamedProcedureCall, getNamedQuery, getNativeJdbcParametersIgnored, getPreferredSqlTypeCodeForBoolean, getResultSetMappingMemento, getSessionIdentifier, getSessionToken, getTenantIdentifier, getTenantIdentifierValue, getTransaction, getTransactionCoordinator, interpretHql, isClosed, isConnected, isCriteriaCopyTreeEnabled, isJoinedToTransaction, isOpen, isOpenOrWaitingForAutoClose, joinTransaction, markForRollbackOnly, prepareForAutoClose, prepareForQueryExecution, pulseTransactionCoordinator, removeSharedSessionTransactionObserver, setClosed, setCriteriaCopyTreeEnabled, setJdbcBatchSize, setNativeJdbcParametersIgnored, setUpMultitenancy, shouldCloseJdbcCoordinatorOnClose, startTransactionBoundary, useStreamForLobBinding
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getSqlExceptionHelper
-
Methods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
fromContext
-
Methods inherited from interface org.hibernate.query.QueryProducer
createMutationQuery, createMutationQuery, createNamedSelectionQuery, createNamedSelectionQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery
-
Methods inherited from interface org.hibernate.SharedSessionContract
beginTransaction, createEntityGraph, createEntityGraph, createEntityGraph, createNamedStoredProcedureQuery, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, disableFilter, doReturningWork, doWork, enableFilter, getCriteriaBuilder, getEnabledFilter, getEntityGraph, getEntityGraphs, getJdbcBatchSize, getNamedProcedureCall, getTenantIdentifier, getTenantIdentifierValue, getTransaction, isConnected, isJoinedToTransaction, isOpen, joinTransaction, setJdbcBatchSize
-
Methods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
asEventSource, asSessionImplementor, autoFlushIfRequired, autoPreFlush, bestGuessEntityName, checkOpen, getSession, getSessionFactory, getTypeConfiguration, isEnforcingFetchGraph, isEventSource, isSessionImplementor, setEnforcingFetchGraph
-
Methods inherited from interface org.hibernate.StatelessSession
close
-
Methods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect
-
-
-
-
Constructor Detail
-
StatelessSessionImpl
public StatelessSessionImpl(SessionFactoryImpl factory, SessionCreationOptions options)
-
-
Method Detail
-
shouldAutoJoinTransaction
public boolean shouldAutoJoinTransaction()
Description copied from interface:TransactionCoordinatorBuilder.OptionsIndicates whether an active transaction should be automatically joined. Only relevant for JTA-based TransactionCoordinator instances.- Specified by:
shouldAutoJoinTransactionin interfaceTransactionCoordinatorBuilder.Options- Overrides:
shouldAutoJoinTransactionin classAbstractSharedSessionContract- Returns:
trueindicates the active transaction should be auto joined;falseindicates it should not (untilTransactionCoordinator.explicitJoin()is called).
-
insert
public Object insert(Object entity)
Description copied from interface:StatelessSessionInsert a record.If the entity
@Idfield is declared to be generated, for example, if it is annotated@GeneratedId, the id is generated and assigned to the given instance.The
PostPersistcallback will be triggered if the operation is successful.- Specified by:
insertin interfaceStatelessSession- Parameters:
entity- a new transient instance- Returns:
- The identifier of the inserted entity
-
insert
public Object insert(String entityName, Object entity)
Description copied from interface:StatelessSessionInsert a record.The
PostPersistcallback will be triggered if the operation is successful.- Specified by:
insertin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be insertedentity- a new transient instance- Returns:
- the identifier of the instance
-
delete
public void delete(Object entity)
Description copied from interface:StatelessSessionDelete a record.The
PostRemovecallback will be triggered if the operation is successful.- Specified by:
deletein interfaceStatelessSession- Parameters:
entity- a detached entity instance
-
delete
public void delete(String entityName, Object entity)
Description copied from interface:StatelessSessionDelete a record.The
PostRemovecallback will be triggered if the operation is successful.- Specified by:
deletein interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be deletedentity- a detached entity instance
-
update
public void update(Object entity)
Description copied from interface:StatelessSessionUpdate a record.The
PostUpdatecallback will be triggered if the operation is successful.- Specified by:
updatein interfaceStatelessSession- Parameters:
entity- a detached entity instance
-
upsert
public void upsert(Object entity)
Description copied from interface:StatelessSessionUse a SQLmerge intostatement to perform an upsert, that is, to insert the record if it does not exist, or update it if it already exists.This method never performs id generation, and does not accept an entity instance with a null identifier. When id generation is required, use
StatelessSession.insert(Object).On the other hand,
upsert()does accept an entity instance with an assigned identifier value, even if the entity@Idfield is declared to be generated, for example, if it is annotated@GeneratedId. Thus, this method may be used to import data from an external source.- Specified by:
upsertin interfaceStatelessSession- Parameters:
entity- a detached entity instance, or a new instance with an assigned identifier
-
update
public void update(String entityName, Object entity)
Description copied from interface:StatelessSessionUpdate a record.The
PostUpdatecallback will be triggered if the operation is successful.- Specified by:
updatein interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be updatedentity- a detached entity instance
-
upsert
public void upsert(String entityName, Object entity)
Description copied from interface:StatelessSessionUse a SQLmerge intostatement to perform an upsert.- Specified by:
upsertin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be mergedentity- a detached entity instance
-
get
public <T> T get(Class<T> entityClass, Object id)
Description copied from interface:StatelessSessionRetrieve a record.- Specified by:
getin interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrieve- Returns:
- a detached entity instance
-
get
public <T> T get(Class<T> entityClass, Object id, LockMode lockMode)
Description copied from interface:StatelessSessionRetrieve a record, obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance
-
get
public Object get(String entityName, Object id)
Description copied from interface:StatelessSessionRetrieve a record.- Specified by:
getin interfaceStatelessSession- Parameters:
entityName- The name of the entity to retrieveid- The id of the entity to retrieve- Returns:
- a detached entity instance
-
get
public Object get(String entityName, Object id, LockMode lockMode)
Description copied from interface:StatelessSessionRetrieve a record, obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
entityName- The name of the entity to retrieveid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance
-
get
public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id)
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraphgraphSemantic- aGraphSemanticspecifying how the graph should be interpretedid- The id of the entity to retrieve- Returns:
- a detached entity instance
-
get
public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id, LockMode lockMode)
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph, and obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraphgraphSemantic- aGraphSemanticspecifying how the graph should be interpretedid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance
-
refresh
public void refresh(Object entity)
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.
-
refresh
public void refresh(String entityName, Object entity)
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be refreshed.entity- The entity to be refreshed.
-
refresh
public void refresh(Object entity, LockMode lockMode)
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
refresh
public void refresh(String entityName, Object entity, LockMode lockMode)
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be refreshed.entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
immediateLoad
public Object immediateLoad(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementorLoad an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Specified by:
immediateLoadin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing) throws HibernateException
Description copied from interface:SharedSessionContractImplementorInitialize the given collection (if not already initialized).- Specified by:
initializeCollectionin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
instantiate
public Object instantiate(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class, initializing with the given identifier.- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
instantiate
public Object instantiate(EntityPersister persister, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class of the givenEntityPersister, initializing the new instance with the given identifier.This is more efficient than
SharedSessionContractImplementor.instantiate(String, Object), but not always interchangeable, since a single persister might be responsible for multiple types.- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable) throws HibernateException
Description copied from interface:SharedSessionContractImplementorObtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.- When
nullable = false, this method may create a new proxy or return an existing proxy; if it does not exist, an exception is thrown. - When
nullable = true, the method does not create new proxies, though it might return an existing proxy; if it does not exist, anullvalue is returned.
When
eager = true, the object is eagerly fetched from the database.- Specified by:
internalLoadin interfaceSharedSessionContractImplementor- Throws:
HibernateException
- When
-
fetch
public void fetch(Object association)
Description copied from interface:StatelessSessionFetch an association or collection that's configured for lazy loading.Book book = session.get(Book.class, isbn); // book is immediately detached session.fetch(book.getAuthors()); // fetch the associated authors book.getAuthors().forEach(author -> ... ); // iterate the collection
Warning: this operation in a stateless session is quite sensitive to data aliasing effects and should be used with great care. It's usually better to fetch associations using eager join fetching.
- Specified by:
fetchin interfaceStatelessSession- Parameters:
association- a lazy-loaded association- See Also:
Hibernate.initialize(Object)
-
getIdentifier
public Object getIdentifier(Object entity) throws HibernateException
Description copied from interface:StatelessSessionReturn the identifier value of the given entity, which may be detached.- Specified by:
getIdentifierin interfaceStatelessSession- Parameters:
entity- a persistent instance associated with this session- Returns:
- the identifier
- Throws:
HibernateException
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()
Description copied from interface:SharedSessionContractImplementorIs auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabledin interfaceSharedSessionContractImplementor- See Also:
TransactionSettings.AUTO_CLOSE_SESSION,SessionFactoryOptions.isAutoCloseSessionEnabled()
-
shouldAutoClose
public boolean shouldAutoClose()
Description copied from interface:SharedSessionContractImplementorShould this session be automatically closed after the current transaction completes?- Specified by:
shouldAutoClosein interfaceSharedSessionContractImplementor
-
bestGuessEntityName
public String bestGuessEntityName(Object object)
Description copied from interface:SharedSessionContractImplementorObtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.- Specified by:
bestGuessEntityNamein interfaceSharedSessionContractImplementor
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SharedSessionContractImplementorGet the currentCacheModefor this session.- Specified by:
getCacheModein interfaceQueryProducerImplementor- Specified by:
getCacheModein interfaceSharedSessionContractImplementor- Overrides:
getCacheModein classAbstractSharedSessionContract
-
setCacheMode
public void setCacheMode(CacheMode cm)
Description copied from interface:SharedSessionContractImplementorSet the currentCacheModefor this session.- Specified by:
setCacheModein interfaceSharedSessionContractImplementor- Overrides:
setCacheModein classAbstractSharedSessionContract
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SharedSessionContractImplementorSet the currentFlushModefor this session.The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.
For a logically "read-only" session, it's reasonable to set the session flush mode to
FlushMode.MANUALat the start of the session (in order skip some work and gain some extra performance).- Specified by:
setHibernateFlushModein interfaceSharedSessionContractImplementor- Overrides:
setHibernateFlushModein classAbstractSharedSessionContract- Parameters:
flushMode- the new flush mode
-
getContextEntityIdentifier
public Object getContextEntityIdentifier(Object object)
Description copied from interface:SharedSessionContractImplementorReturn the identifier of the persistent object, or null if it is not associated with this session.- Specified by:
getContextEntityIdentifierin interfaceSharedSessionContractImplementor
-
guessEntityName
public String guessEntityName(Object entity) throws HibernateException
Description copied from interface:SharedSessionContractImplementorObtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.- Specified by:
guessEntityNamein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getEntityPersister
public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException
Description copied from interface:SharedSessionContractImplementorGet theEntityPersisterfor the given entity instance.- Specified by:
getEntityPersisterin interfaceSharedSessionContractImplementor- Parameters:
entityName- optional entity nameobject- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
Description copied from interface:SharedSessionContractImplementorGet the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.- Specified by:
getEntityUsingInterceptorin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getPersistenceContext
public PersistenceContext getPersistenceContext()
Description copied from interface:SharedSessionContractImplementorGet the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()for a faster alternative.- Specified by:
getPersistenceContextin interfaceSharedSessionContractImplementor
-
setAutoClear
public void setAutoClear(boolean enabled)
Description copied from interface:SharedSessionContractImplementorEnable or disable automatic cache clearing from after transaction completion.- Specified by:
setAutoClearin interfaceSharedSessionContractImplementor
-
load
protected Object load(String entityName, Object identifier)
- Specified by:
loadin classAbstractSharedSessionContract
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SharedSessionContractImplementorAre entities and proxies loaded by this session read-only by default?- Specified by:
isDefaultReadOnlyin interfaceSharedSessionContractImplementor
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean readOnly) throws HibernateException- Throws:
HibernateException
-
afterOperation
public void afterOperation(boolean success)
Description copied from interface:SharedSessionContractImplementorCheck if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.- Specified by:
afterOperationin interfaceSharedSessionContractImplementor- Parameters:
success-trueif the operation a success
-
afterScrollOperation
public void afterScrollOperation()
Description copied from interface:SharedSessionContractImplementorCalled after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context. For a stateful session, this method does nothing.- Specified by:
afterScrollOperationin interfaceSharedSessionContractImplementor
-
flush
public void flush()
Description copied from interface:SharedSessionContractImplementorFlush this session.- Specified by:
flushin interfaceSharedSessionContractImplementor
-
getLoadQueryInfluencers
public LoadQueryInfluencers getLoadQueryInfluencers()
Description copied from interface:SharedSessionContractImplementorGet theLoadQueryInfluencersassociated with this session.- Specified by:
getLoadQueryInfluencersin interfaceSharedSessionContractImplementor- Returns:
- the
LoadQueryInfluencersassociated with this session; should never be null.
-
getPersistenceContextInternal
public PersistenceContext getPersistenceContextInternal()
Description copied from interface:SharedSessionContractImplementorSimilar toSharedSessionContractImplementor.getPersistenceContext(), with two differences:- this version performs better as it allows for inlining and probably better prediction, and
- it skips some checks of the current state of the session.
- Specified by:
getPersistenceContextInternalin interfaceSharedSessionContractImplementor- Returns:
- the
PersistenceContextassociated to this session.
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces) throws HibernateException
Description copied from interface:SharedSessionContractImplementordetect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequiredin interfaceSharedSessionContractImplementor- Parameters:
querySpaces- the tables named in the query.- Returns:
- true if flush is required, false otherwise.
- Throws:
HibernateException
-
afterTransactionBegin
public void afterTransactionBegin()
Description copied from interface:JdbcSessionOwnerA after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBeginin interfaceJdbcSessionOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:JdbcSessionOwnerA before-completion callback to the owner.- Specified by:
beforeTransactionCompletionin interfaceJdbcSessionOwner- Overrides:
beforeTransactionCompletionin classAbstractSharedSessionContract
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed)Description copied from interface:JdbcSessionOwnerAn after-completion callback to the owner.- Specified by:
afterTransactionCompletionin interfaceJdbcSessionOwner- Overrides:
afterTransactionCompletionin classAbstractSharedSessionContract- Parameters:
successful- Was the transaction successful?delayed- Is this a delayed after transaction completion call (aka after a timeout)?
-
isTransactionInProgress
public boolean isTransactionInProgress()
Description copied from interface:SharedSessionContractImplementorDoes this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgressin interfaceSharedSessionContractImplementor- Overrides:
isTransactionInProgressin classAbstractSharedSessionContract
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()
- Specified by:
flushBeforeTransactionCompletionin interfaceJdbcSessionOwner
-
asStatelessSession
public StatelessSession asStatelessSession()
Description copied from interface:SharedSessionContractImplementorCast this object toStatelessSession, if possible.- Specified by:
asStatelessSessionin interfaceSharedSessionContractImplementor
-
isStatelessSession
public boolean isStatelessSession()
Description copied from interface:SharedSessionContractImplementorDoes this object implementStatelessSession?- Specified by:
isStatelessSessionin interfaceSharedSessionContractImplementor
-
-