Class StatelessSessionImpl
- All Implemented Interfaces:
Serializable,AutoCloseable,LobCreationContext,SharedSessionContractImplementor,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,SharedSessionContract,StatelessSession,JavaType.CoercionContext,WrapperOptions
StatelessSession API.
Exposes two interfaces:
StatelessSessionto the application, andSharedSessionContractImplementor(an SPI interface) to other subsystems.
This class is not thread-safe.
- See Also:
- Implementation Note:
- The
StatelessSessionImplis not anEventSourceand does not make use of the usual eventing infrastructure to implement persistence operations. It does raise pre- and post- events for the benefit of integration, however. Since it performs all operations synchronously, it does not maintain anActionQueue. Therefore, it cannot, unfortunately, reuse the variousEntityActionsubtypes. This is a pity, since it results in some code duplication. On the other hand, aStatelessSessionis easier to debug and understand. AStatelessSessiondoes hold state in a long-livedPersistenceContext, but it does temporarily keep state within an instance ofStatefulPersistenceContextwhile processing the results of a given query.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.Callback<T> -
Field Summary
FieldsFields inherited from class org.hibernate.internal.AbstractSharedSessionContract
closed, waitingForAutoClose -
Constructor Summary
ConstructorsConstructorDescriptionStatelessSessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) -
Method Summary
Modifier and TypeMethodDescriptionvoidafterOperation(boolean success) Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.voidCalled after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context.voidAn after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed) An after-completion callback to the owner.booleanautoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush) detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushvoidvoidA before-completion callback to the owner.bestGuessEntityName(Object object) Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.voidDelete a record.voidDelete a record.voiddeleteMultiple(List<?> entities) Delete multiple records.voidFetch an association or collection that's configured for lazy loading.protected voidfirePostDelete(Object entity, Object id, EntityPersister persister) protected voidfirePostInsert(Object entity, Object id, Object[] state, EntityPersister persister) protected voidfirePostRecreate(PersistentCollection<?> collection, Object id, String entityName, Object owner) protected voidfirePostRemove(PersistentCollection<?> collection, Object id, String entityName, Object owner) protected voidfirePostUpdate(Object entity, Object id, Object[] state, EntityPersister persister) protected voidfirePostUpdate(PersistentCollection<?> collection, Object id, String entityName, Object owner) protected voidfirePostUpsert(Object entity, Object id, Object[] state, EntityPersister persister) protected booleanfirePreDelete(Object entity, Object id, EntityPersister persister) protected booleanfirePreInsert(Object entity, Object id, Object[] state, EntityPersister persister) protected voidfirePreRecreate(PersistentCollection<?> collection, Object id, String entityName, Object owner) protected voidfirePreRemove(PersistentCollection<?> collection, Object id, String entityName, Object owner) protected booleanfirePreUpdate(Object entity, Object id, Object[] state, EntityPersister persister) protected voidfirePreUpdate(PersistentCollection<?> collection, Object id, String entityName, Object owner) protected booleanfirePreUpsert(Object entity, Object id, Object[] state, EntityPersister persister) voidflush()Flush this session.voidprotected voidforEachOwnedCollection(Object entity, Object key, EntityPersister persister, BiConsumer<CollectionPersister, PersistentCollection<?>> action) <T> Tget(EntityGraph<T> graph, Object id) Retrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph.<T> Tget(EntityGraph<T> graph, Object id, LockMode lockMode) Retrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph, and obtaining the specified lock mode.<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> TRetrieve a record.<T> TRetrieve a record, obtaining the specified lock mode.Retrieve a record.Retrieve a record, obtaining the specified lock mode.getContextEntityIdentifier(Object object) Return the identifier of the persistent object, or null if it is not associated with this session.getEntityPersister(String entityName, Object entity) Get theEntityPersisterfor the given entity instance.Get the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.Get the currentFlushModefor this session.getIdentifier(Object entity) Return the identifier value of the given entity, which may be detached.Get theLoadQueryInfluencersassociated with this session.<T> List<T> getMultiple(EntityGraph<T> entityGraph, List<?> ids) Retrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.<T> List<T> getMultiple(EntityGraph<T> entityGraph, GraphSemantic graphSemantic, List<?> ids) Retrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.<T> List<T> getMultiple(Class<T> entityClass, List<?> ids) Retrieve multiple rows, returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.<T> List<T> getMultiple(Class<T> entityClass, List<?> ids, LockMode lockMode) Retrieve multiple rows, obtaining the specified lock mode, and returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.Get the persistence context for this session.Similar toSharedSessionContractImplementor.getPersistenceContext(), with two differences: this version performs better as it allows for inlining and probably better prediction, and it skips some checks of the current state of the session.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.protected ObjectidToUpsert(Object entity, EntityPersister persister) immediateLoad(String entityName, Object id) Load an instance immediately.voidinitializeCollection(PersistentCollection<?> collection, boolean writing) Initialize the given collection (if not already initialized).Insert a record.Insert a record.voidinsertMultiple(List<?> entities) Insert multiple records.instantiate(String entityName, Object id) Deprecated.instantiate(EntityPersister persister, Object id) Instantiate the entity class of the givenEntityPersister, initializing the new instance with the given identifier.protected PersistentCollection<?> instantiateEmpty(Object key, CollectionPersister descriptor) 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 ObjectinternalLoadGet(String entityName, Object id, PersistenceContext persistenceContext) booleanbooleanAre entities and proxies loaded by this session read-only by default?booleanbooleanDoes this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?loadFromSecondLevelCache(EntityPersister persister, EntityKey entityKey, Object instanceToLoad, LockMode lockMode) Attempts to load the entity from the second-level cache.voidlock(String entityName, Object child, LockOptions lockOptions) Cascade the lock operation to the given child entity.protected ObjectlockCacheItem(Object id, Object previousVersion, EntityPersister persister) protected ObjectlockCacheItem(Object key, CollectionPersister persister) voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRegisters the given process for execution after transaction completion.protected voidremoveCacheItem(Object ck, CollectionPersister persister) protected voidremoveCacheItem(Object ck, EntityPersister persister) booleanbooleanIndicates whether an active transaction should be automatically joined.<T> TReturn an object of the specified type to allow access to a provider-specific API.voidUpdate a record.voidUpdate a record.voidupdateMultiple(List<?> entities) Update multiple records.voidUse 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.voidUse a SQLmerge intostatement to perform an upsert.voidupsertMultiple(List<?> entities) Perform an upsert, that is, to insert the record if it does not exist, or update the record if it already exists, for each given record.protected ObjectversionToUpsert(Object entity, EntityPersister persister, Object[] state) protected PersistentCollection<?> wrap(CollectionPersister descriptor, Object collection, Object owner) Methods inherited from class org.hibernate.internal.AbstractSharedSessionContract
accessTransaction, addSharedSessionTransactionObserver, afterObtainConnection, applyQuerySettingsAndHints, applyQuerySettingsAndHints, beforeReleaseConnection, beginTransaction, buildNamedQuery, checkMutationQuery, checkOpen, checkResultType, checkSelectionQuery, checkTransactionNeededForUpdateOperation, checkTransactionSynchStatus, cleanupOnClose, close, createCriteriaQuery, createEntityGraph, createEntityGraph, createEntityGraph, createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNamedSelectionQuery, createNamedSelectionQuery, createNamedStoredProcedureQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQueryImplementor, createNativeQueryImplementor, createNativeQueryImplementor, createQuery, createQuery, createQuery, createQuery, createQuery, createQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, createSqmQueryImplementor, createSqmQueryImplementor, createSqmQueryImplementor, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, delayedAfterCompletion, disableFilter, doReturningWork, doWork, enableFilter, execute, generateEntityKey, getCacheMode, getCacheTransactionSynchronization, getConfiguredJdbcBatchSize, getCriteriaBuilder, getCurrentTransaction, getDialect, getEnabledFilter, getEntityGraph, getEntityGraphs, getEntityNameResolver, getEventListenerManager, getEventMonitor, getExceptionConverter, getFactory, getInterceptor, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcCoordinator, getJdbcServices, getJdbcSessionContext, getJdbcTimeZone, getJsonFormatMapper, getLobCreator, getNamedNativeQuery, getNamedNativeQuery, getNamedProcedureCall, getNamedQuery, getNativeJdbcParametersIgnored, getPreferredSqlTypeCodeForBoolean, getResultSetMappingMemento, getSessionAssociationMarkers, getSessionFactory, getSessionIdentifier, getSessionToken, getTenantIdentifier, getTenantIdentifierValue, getTransaction, getTransactionCoordinator, getTypeConfiguration, getXmlFormatMapper, interpretHql, isClosed, isConnected, isCriteriaCopyTreeEnabled, isCriteriaPlanCacheEnabled, isJoinedToTransaction, isOpen, isOpenOrWaitingForAutoClose, joinTransaction, markForRollbackOnly, prepareForAutoClose, prepareForQueryExecution, pulseTransactionCoordinator, removeSharedSessionTransactionObserver, requireCollectionPersister, requireEntityPersister, requireEntityPersister, setCacheMode, setClosed, setCriteriaCopyTreeEnabled, setCriteriaPlanCacheEnabled, setJdbcBatchSize, setNativeJdbcParametersIgnored, setUpMultitenancy, shouldCloseJdbcCoordinatorOnClose, startTransactionBoundary, useStreamForLobBindingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getEventManager, getSqlExceptionHelperMethods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
fromContextMethods inherited from interface org.hibernate.query.QueryProducer
createMutationQuery, createNamedSelectionQuery, createNamedSelectionQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, createSelectionQueryMethods inherited from interface org.hibernate.SharedSessionContract
beginTransaction, createEntityGraph, createNamedStoredProcedureQuery, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, disableFilter, doReturningWork, doWork, enableFilter, fromTransaction, getCacheMode, getCriteriaBuilder, getEnabledFilter, getEntityGraphs, getJdbcBatchSize, getNamedProcedureCall, getTenantIdentifier, getTenantIdentifierValue, getTransaction, inTransaction, isConnected, isJoinedToTransaction, isOpen, joinTransaction, setCacheMode, setJdbcBatchSizeMethods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
asEventSource, asSessionImplementor, asStatelessSession, autoFlushIfRequired, bestGuessEntityName, checkOpen, getSession, isEventSource, isSessionImplementor, isStatelessSessionMethods inherited from interface org.hibernate.StatelessSession
close
-
Field Details
-
MULTI_ID_LOAD_OPTIONS
-
-
Constructor Details
-
StatelessSessionImpl
-
-
Method Details
-
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).
-
getHibernateFlushMode
Description copied from interface:SharedSessionContractImplementorGet the currentFlushModefor this session.- Specified by:
getHibernateFlushModein interfaceQueryProducerImplementor- Specified by:
getHibernateFlushModein interfaceSharedSessionContractImplementor- Returns:
- The flush mode
-
insert
Description copied from interface:StatelessSessionInsert a record.If the entity
@Idfield is declared to be generated, for example, if it is annotated@GeneratedValue, 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
-
insertMultiple
Description copied from interface:StatelessSessionInsert multiple records.- Specified by:
insertMultiplein interfaceStatelessSession- Parameters:
entities- a list of transient instances to be inserted
-
insert
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
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
-
deleteMultiple
Description copied from interface:StatelessSessionDelete multiple records.- Specified by:
deleteMultiplein interfaceStatelessSession- Parameters:
entities- a list of detached instances to be deleted
-
delete
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
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
-
updateMultiple
Description copied from interface:StatelessSessionUpdate multiple records.- Specified by:
updateMultiplein interfaceStatelessSession- Parameters:
entities- a list of detached instances to be updated
-
update
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
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@GeneratedValue. 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
-
upsertMultiple
Description copied from interface:StatelessSessionPerform an upsert, that is, to insert the record if it does not exist, or update the record if it already exists, for each given record.- Specified by:
upsertMultiplein interfaceStatelessSession- Parameters:
entities- a list of detached instances and new instances with assigned identifiers
-
upsert
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
-
versionToUpsert
-
idToUpsert
-
firePreInsert
protected boolean firePreInsert(Object entity, Object id, Object[] state, EntityPersister persister) -
firePreUpdate
protected boolean firePreUpdate(Object entity, Object id, Object[] state, EntityPersister persister) -
firePreUpsert
protected boolean firePreUpsert(Object entity, Object id, Object[] state, EntityPersister persister) -
firePreDelete
-
firePostInsert
-
firePostUpdate
-
firePostUpsert
-
firePostDelete
-
firePreRecreate
protected void firePreRecreate(PersistentCollection<?> collection, Object id, String entityName, Object owner) -
firePreUpdate
protected void firePreUpdate(PersistentCollection<?> collection, Object id, String entityName, Object owner) -
firePreRemove
protected void firePreRemove(PersistentCollection<?> collection, Object id, String entityName, Object owner) -
firePostRecreate
protected void firePostRecreate(PersistentCollection<?> collection, Object id, String entityName, Object owner) -
firePostUpdate
protected void firePostUpdate(PersistentCollection<?> collection, Object id, String entityName, Object owner) -
firePostRemove
protected void firePostRemove(PersistentCollection<?> collection, Object id, String entityName, Object owner) -
forEachOwnedCollection
protected void forEachOwnedCollection(Object entity, Object key, EntityPersister persister, BiConsumer<CollectionPersister, PersistentCollection<?>> action) -
instantiateEmpty
-
wrap
protected PersistentCollection<?> wrap(CollectionPersister descriptor, Object collection, Object owner) -
get
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, or null if there is no instance with the given id
-
get
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, or null if there is no instance with the given id
-
get
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, or null if there is no instance with the given id
-
get
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, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraph, interpreted as a load graphid- The id of the entity to retrieve- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph, and obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraph, interpreted as a load graphid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
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, or null if there is no instance with the given id
-
get
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, or null if there is no instance with the given id
-
getMultiple
Description copied from interface:StatelessSessionRetrieve multiple rows, obtaining the specified lock mode, and returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveids- The ids of the entities to retrievelockMode- The lock mode to apply to the entities- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
getMultiple
Description copied from interface:StatelessSessionRetrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityGraph- TheEntityGraph, interpreted as a load graphids- The ids of the entities to retrieve- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
getMultiple
public <T> List<T> getMultiple(EntityGraph<T> entityGraph, GraphSemantic graphSemantic, List<?> ids) Description copied from interface:StatelessSessionRetrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityGraph- TheEntityGraphgraphSemantic- aGraphSemanticspecifying how the graph should be interpretedids- The ids of the entities to retrieve- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
getMultiple
Description copied from interface:StatelessSessionRetrieve multiple rows, returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveids- The ids of the entities to retrieve- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.
-
refresh
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
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
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
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
-
initializeCollection
Description copied from interface:SharedSessionContractImplementorInitialize the given collection (if not already initialized).- Specified by:
initializeCollectionin interfaceSharedSessionContractImplementor
-
instantiate
Deprecated.Description copied from interface:SharedSessionContractImplementorInstantiate the entity class, initializing with the given identifier.- Specified by:
instantiatein interfaceSharedSessionContractImplementor
-
instantiate
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
-
internalLoad
Description copied from interface:SharedSessionContractImplementorObtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.- When
nullable = false, this method may create a new proxy or return an existing proxy; if it does not exist, an exception is thrown. - When
nullable = true, the method does not create new proxies, though it might return an existing proxy; if it does not exist, anullvalue is returned.
When
eager = true, the object is eagerly fetched from the database.- Specified by:
internalLoadin interfaceSharedSessionContractImplementor
- When
-
internalLoadGet
protected Object internalLoadGet(String entityName, Object id, PersistenceContext persistenceContext) -
fetch
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:
-
getIdentifier
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
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled() -
shouldAutoClose
public boolean shouldAutoClose() -
bestGuessEntityName
Description copied from interface:SharedSessionContractImplementorObtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.- Specified by:
bestGuessEntityNamein interfaceSharedSessionContractImplementor
-
getContextEntityIdentifier
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
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
-
getEntityPersister
Description copied from interface:SharedSessionContractImplementorGet theEntityPersisterfor the given entity instance.- Specified by:
getEntityPersisterin interfaceSharedSessionContractImplementor- Parameters:
entityName- optional entity nameentity- the entity instance
-
getEntityUsingInterceptor
Description copied from interface:SharedSessionContractImplementorGet the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.- Specified by:
getEntityUsingInterceptorin interfaceSharedSessionContractImplementor
-
getPersistenceContext
Description copied from interface:SharedSessionContractImplementorGet the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()for a faster alternative.- Specified by:
getPersistenceContextin interfaceSharedSessionContractImplementor
-
isDefaultReadOnly
public boolean isDefaultReadOnly()Description copied from interface:SharedSessionContractImplementorAre entities and proxies loaded by this session read-only by default?- Specified by:
isDefaultReadOnlyin interfaceSharedSessionContractImplementor
-
isIdentifierRollbackEnabled
public boolean isIdentifierRollbackEnabled()- Specified by:
isIdentifierRollbackEnabledin interfaceSharedSessionContractImplementor
-
afterOperation
public void afterOperation(boolean success) Description copied from interface:SharedSessionContractImplementorCheck if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.- Specified by:
afterOperationin 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
-
autoPreFlush
public void autoPreFlush()- Specified by:
autoPreFlushin interfaceSharedSessionContractImplementor
-
flush
public void flush()Description copied from interface:SharedSessionContractImplementorFlush this session.- Specified by:
flushin interfaceSharedSessionContractImplementor
-
getLoadQueryInfluencers
Description copied from interface:SharedSessionContractImplementorGet theLoadQueryInfluencersassociated with this session.- Specified by:
getLoadQueryInfluencersin interfaceSharedSessionContractImplementor- Returns:
- the
LoadQueryInfluencersassociated with this session; should never be null.
-
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
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.skipPreFlush- seeAutoFlushEvent.isSkipPreFlush()- Returns:
- true if flush is required, false otherwise.
-
afterTransactionBegin
public void afterTransactionBegin()Description copied from interface:JdbcSessionOwnerAn 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
-
lockCacheItem
-
removeCacheItem
-
lockCacheItem
-
removeCacheItem
-
registerProcess
Description copied from interface:SharedSessionContractImplementorRegisters the given process for execution after transaction completion.- Specified by:
registerProcessin interfaceSharedSessionContractImplementor- Parameters:
process- The process to register
-
lock
Description copied from interface:SharedSessionContractImplementorCascade the lock operation to the given child entity.- Specified by:
lockin interfaceSharedSessionContractImplementor
-
loadFromSecondLevelCache
public Object loadFromSecondLevelCache(EntityPersister persister, EntityKey entityKey, Object instanceToLoad, LockMode lockMode) Description copied from interface:SharedSessionContractImplementorAttempts to load the entity from the second-level cache.- Specified by:
loadFromSecondLevelCachein interfaceSharedSessionContractImplementor- Parameters:
persister- The persister for the entity being requested for loadentityKey- The entity keyinstanceToLoad- The instance that is being initialized, or nulllockMode- The lock mode- Returns:
- The entity from the second-level cache, or null.
-
unwrap
Description copied from interface:SharedSessionContractReturn an object of the specified type to allow access to a provider-specific API.- Specified by:
unwrapin interfaceSharedSessionContract- Parameters:
type- the class of the object to be returned. This is usually either the underlying class implementingSharedSessionContractor an interface it implements.- Returns:
- an instance of the specified class
-