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 theStatelessSession
API.Exposes two interfaces:
StatelessSession
to 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 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.StatelessSession
asStatelessSession()
Cast this object toStatelessSession
, 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.void
delete(Object entity)
Delete a record.void
delete(String entityName, Object entity)
Delete a record.void
fetch(Object association)
Fetch an association or collection that's configured for lazy loading.void
flush()
Flush this session.void
flushBeforeTransactionCompletion()
<T> T
get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id)
Retrieve a record, fetching associations specified by the givenEntityGraph
.<T> T
get(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> T
get(Class<T> entityClass, Object id)
Retrieve a record.<T> T
get(Class<T> entityClass, Object id, LockMode lockMode)
Retrieve a record, obtaining the specified lock mode.Object
get(String entityName, Object id)
Retrieve a record.Object
get(String entityName, Object id, LockMode lockMode)
Retrieve a record, obtaining the specified lock mode.CacheMode
getCacheMode()
Get the currentCacheMode
for this session.Object
getContextEntityIdentifier(Object object)
Return the identifier of the persistent object, or null if it is not associated with this session.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 entity)
Return the identifier value of the given entity, which may be detached.LoadQueryInfluencers
getLoadQueryInfluencers()
Get theLoadQueryInfluencers
associated with this session.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.String
guessEntityName(Object entity)
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.Object
immediateLoad(String entityName, Object id)
Load an instance immediately.void
initializeCollection(PersistentCollection<?> collection, boolean writing)
Initialize the given collection (if not already initialized).Object
insert(Object entity)
Insert a record.Object
insert(String entityName, Object entity)
Insert a record.Object
instantiate(String entityName, Object id)
Instantiate the entity class, initializing with the given identifier.Object
instantiate(EntityPersister persister, Object id)
Instantiate the entity class of the givenEntityPersister
, initializing the new instance with the given identifier.Object
internalLoad(String entityName, Object id, boolean eager, boolean nullable)
Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.boolean
isAutoCloseSessionEnabled()
Is auto-close at transaction completion enabled?boolean
isDefaultReadOnly()
Are entities and proxies loaded by this session read-only by default?boolean
isStatelessSession()
Does this object implementStatelessSession
?boolean
isTransactionInProgress()
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?protected Object
load(String entityName, Object identifier)
void
refresh(Object entity)
Refresh the entity instance state from the database.void
refresh(Object entity, LockMode lockMode)
Refresh the entity instance state from the database.void
refresh(String entityName, Object entity)
Refresh the entity instance state from the database.void
refresh(String entityName, Object entity, LockMode lockMode)
Refresh the entity instance state from the database.void
setAutoClear(boolean enabled)
Enable or disable automatic cache clearing from after transaction completion.void
setCacheMode(CacheMode cm)
Set the currentCacheMode
for this session.void
setDefaultReadOnly(boolean readOnly)
void
setHibernateFlushMode(FlushMode flushMode)
Set the currentFlushMode
for this session.boolean
shouldAutoClose()
Should this session be automatically closed after the current transaction completes?boolean
shouldAutoJoinTransaction()
Indicates whether an active transaction should be automatically joined.void
update(Object entity)
Update a record.void
update(String entityName, Object entity)
Update a record.void
upsert(Object entity)
Use a SQLmerge into
statement to perform an upsert, that is, to insert the record if it does not exist, or update it if it already exists.void
upsert(String entityName, Object entity)
Use a SQLmerge into
statement 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.Options
Indicates whether an active transaction should be automatically joined. Only relevant for JTA-based TransactionCoordinator instances.- Specified by:
shouldAutoJoinTransaction
in interfaceTransactionCoordinatorBuilder.Options
- Overrides:
shouldAutoJoinTransaction
in classAbstractSharedSessionContract
- Returns:
true
indicates the active transaction should be auto joined;false
indicates it should not (untilTransactionCoordinator.explicitJoin()
is called).
-
insert
public Object insert(Object entity)
Description copied from interface:StatelessSession
Insert a record.If the entity
@Id
field is declared to be generated, for example, if it is annotated@GeneratedId
, the id is generated and assigned to the given instance.The
PostPersist
callback will be triggered if the operation is successful.- Specified by:
insert
in 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:StatelessSession
Insert a record.The
PostPersist
callback will be triggered if the operation is successful.- Specified by:
insert
in 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:StatelessSession
Delete a record.The
PostRemove
callback will be triggered if the operation is successful.- Specified by:
delete
in interfaceStatelessSession
- Parameters:
entity
- a detached entity instance
-
delete
public void delete(String entityName, Object entity)
Description copied from interface:StatelessSession
Delete a record.The
PostRemove
callback will be triggered if the operation is successful.- Specified by:
delete
in 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:StatelessSession
Update a record.The
PostUpdate
callback will be triggered if the operation is successful.- Specified by:
update
in interfaceStatelessSession
- Parameters:
entity
- a detached entity instance
-
upsert
public void upsert(Object entity)
Description copied from interface:StatelessSession
Use a SQLmerge into
statement 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@Id
field 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:
upsert
in 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:StatelessSession
Update a record.The
PostUpdate
callback will be triggered if the operation is successful.- Specified by:
update
in 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:StatelessSession
Use a SQLmerge into
statement to perform an upsert.- Specified by:
upsert
in 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:StatelessSession
Retrieve a record.- Specified by:
get
in 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:StatelessSession
Retrieve a record, obtaining the specified lock mode.- Specified by:
get
in 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:StatelessSession
Retrieve a record.- Specified by:
get
in 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:StatelessSession
Retrieve a record, obtaining the specified lock mode.- Specified by:
get
in 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:StatelessSession
Retrieve a record, fetching associations specified by the givenEntityGraph
.- Specified by:
get
in interfaceStatelessSession
- Parameters:
graph
- TheEntityGraph
graphSemantic
- aGraphSemantic
specifying 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:StatelessSession
Retrieve a record, fetching associations specified by the givenEntityGraph
, and obtaining the specified lock mode.- Specified by:
get
in interfaceStatelessSession
- Parameters:
graph
- TheEntityGraph
graphSemantic
- aGraphSemantic
specifying 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:StatelessSession
Refresh the entity instance state from the database.- Specified by:
refresh
in interfaceStatelessSession
- Parameters:
entity
- The entity to be refreshed.
-
refresh
public void refresh(String entityName, Object entity)
Description copied from interface:StatelessSession
Refresh the entity instance state from the database.- Specified by:
refresh
in 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:StatelessSession
Refresh the entity instance state from the database.- Specified by:
refresh
in 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:StatelessSession
Refresh the entity instance state from the database.- Specified by:
refresh
in 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:SharedSessionContractImplementor
Load an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Specified by:
immediateLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Initialize the given collection (if not already initialized).- Specified by:
initializeCollection
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
instantiate
public Object instantiate(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Instantiate the entity class, initializing with the given identifier.- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
instantiate
public Object instantiate(EntityPersister persister, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Instantiate the entity class of the givenEntityPersister
, initializing the new instance with the given identifier.This is more efficient than
SharedSessionContractImplementor.instantiate(String, Object)
, but not always interchangeable, since a single persister might be responsible for multiple types.- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.- When
nullable = false
, this method may create a new proxy or return an existing proxy; if it does not exist, an exception is thrown. - When
nullable = true
, the method does not create new proxies, though it might return an existing proxy; if it does not exist, anull
value is returned.
When
eager = true
, the object is eagerly fetched from the database.- Specified by:
internalLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
- When
-
fetch
public void fetch(Object association)
Description copied from interface:StatelessSession
Fetch 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:
fetch
in interfaceStatelessSession
- Parameters:
association
- a lazy-loaded association- See Also:
Hibernate.initialize(Object)
-
getIdentifier
public Object getIdentifier(Object entity) throws HibernateException
Description copied from interface:StatelessSession
Return the identifier value of the given entity, which may be detached.- Specified by:
getIdentifier
in interfaceStatelessSession
- Parameters:
entity
- a persistent instance associated with this session- Returns:
- the identifier
- Throws:
HibernateException
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()
Description copied from interface:SharedSessionContractImplementor
Is auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabled
in interfaceSharedSessionContractImplementor
- See Also:
TransactionSettings.AUTO_CLOSE_SESSION
,SessionFactoryOptions.isAutoCloseSessionEnabled()
-
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
-
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
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SharedSessionContractImplementor
Get the currentCacheMode
for this session.- Specified by:
getCacheMode
in interfaceQueryProducerImplementor
- Specified by:
getCacheMode
in interfaceSharedSessionContractImplementor
- Overrides:
getCacheMode
in classAbstractSharedSessionContract
-
setCacheMode
public void setCacheMode(CacheMode cm)
Description copied from interface:SharedSessionContractImplementor
Set the currentCacheMode
for this session.- Specified by:
setCacheMode
in interfaceSharedSessionContractImplementor
- Overrides:
setCacheMode
in classAbstractSharedSessionContract
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SharedSessionContractImplementor
Set the currentFlushMode
for this session.The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.
For a logically "read-only" session, it's reasonable to set the session flush mode to
FlushMode.MANUAL
at the start of the session (in order skip some work and gain some extra performance).- Specified by:
setHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Overrides:
setHibernateFlushMode
in classAbstractSharedSessionContract
- Parameters:
flushMode
- the new flush mode
-
getContextEntityIdentifier
public Object getContextEntityIdentifier(Object object)
Description copied from interface:SharedSessionContractImplementor
Return the identifier of the persistent object, or null if it is not associated with this session.- Specified by:
getContextEntityIdentifier
in interfaceSharedSessionContractImplementor
-
guessEntityName
public String guessEntityName(Object entity) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.- Specified by:
guessEntityName
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getEntityPersister
public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Get theEntityPersister
for the given entity instance.- Specified by:
getEntityPersister
in interfaceSharedSessionContractImplementor
- Parameters:
entityName
- optional entity nameobject
- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.- Specified by:
getEntityUsingInterceptor
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
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
-
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
-
load
protected Object load(String entityName, Object identifier)
- Specified by:
load
in classAbstractSharedSessionContract
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SharedSessionContractImplementor
Are entities and proxies loaded by this session read-only by default?- Specified by:
isDefaultReadOnly
in interfaceSharedSessionContractImplementor
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean readOnly) throws HibernateException
- Throws:
HibernateException
-
afterOperation
public void afterOperation(boolean success)
Description copied from interface:SharedSessionContractImplementor
Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.- Specified by:
afterOperation
in interfaceSharedSessionContractImplementor
- Parameters:
success
-true
if the operation a success
-
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
-
flush
public void flush()
Description copied from interface:SharedSessionContractImplementor
Flush this session.- Specified by:
flush
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.
-
getPersistenceContextInternal
public PersistenceContext getPersistenceContextInternal()
Description copied from interface:SharedSessionContractImplementor
Similar toSharedSessionContractImplementor.getPersistenceContext()
, with two differences:- this version performs better as it allows for inlining and probably better prediction, and
- it skips some checks of the current state of the session.
- Specified by:
getPersistenceContextInternal
in interfaceSharedSessionContractImplementor
- Returns:
- the
PersistenceContext
associated to this session.
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces) throws HibernateException
Description copied from interface:SharedSessionContractImplementor
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequired
in interfaceSharedSessionContractImplementor
- Parameters:
querySpaces
- the tables named in the query.- Returns:
- true if flush is required, false otherwise.
- Throws:
HibernateException
-
afterTransactionBegin
public void afterTransactionBegin()
Description copied from interface:JdbcSessionOwner
A after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBegin
in interfaceJdbcSessionOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:JdbcSessionOwner
A before-completion callback to the owner.- Specified by:
beforeTransactionCompletion
in interfaceJdbcSessionOwner
- 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)?
-
isTransactionInProgress
public boolean isTransactionInProgress()
Description copied from interface:SharedSessionContractImplementor
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgress
in interfaceSharedSessionContractImplementor
- Overrides:
isTransactionInProgress
in classAbstractSharedSessionContract
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()
- Specified by:
flushBeforeTransactionCompletion
in interfaceJdbcSessionOwner
-
asStatelessSession
public StatelessSession asStatelessSession()
Description copied from interface:SharedSessionContractImplementor
Cast this object toStatelessSession
, if possible.- Specified by:
asStatelessSession
in interfaceSharedSessionContractImplementor
-
isStatelessSession
public boolean isStatelessSession()
Description copied from interface:SharedSessionContractImplementor
Does this object implementStatelessSession
?- Specified by:
isStatelessSession
in interfaceSharedSessionContractImplementor
-
-