Session API.
Exposes two interfaces:
Session to the application, and
SessionImplementor and EventSource (both SPI interfaces) to other subsystems.
This class is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private class | SessionImpl.LockRequestImpl
Deprecated
|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private transient ActionQueue | |
| private boolean | |
| private final boolean | |
| private transient boolean | |
| private transient LoadEvent | |
| private transient LoadQueryInfluencers | |
| private transient SessionImpl. | |
| private LockOptions | |
| private static final EntityManagerMessageLogger | |
| private transient StatefulPersistenceContext | |
| private Map | |
| private transient TransactionObserver | transactionObserver
Deprecated
as a consequence of
TransactionObserver being deprecated.
|
| Access | Constructor and Description |
|---|---|
| public | SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options)
Deprecated
as a consequence of
SessionFactoryImpl being deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
| public void | addEventListeners(SessionEventListener...
the listener(s) to add listeners)Implements org. |
| protected void | |
| public void | afterOperation(boolean
true if the operation a successImplements org. |
| public void | afterScrollOperation()
Implements org. org.,
providing an opportunity for a stateless session to clear its
temporary persistence context.
|
| public void | afterTransactionBegin()
Implements org. |
| public void | afterTransactionCompletion(boolean
Was the transaction successful? successful, boolean Is this a delayed after transaction completion call (aka after a timeout)? delayed)Overrides org. Implements org. |
| protected void | |
| protected void | |
| protected void | |
| public EventSource | asEventSource()
Overrides default org. EventSource if possible.
|
| public boolean | autoFlushIfRequired(Set<String>
the tables named in the query. querySpaces)Implements org. |
| public void | beforeTransactionCompletion()
Overrides org. Implements org. |
| public String | bestGuessEntityName(Object object)
Implements org. |
| public String | bestGuessEntityName(Object object, EntityEntry entry)
Overrides default org. |
| private LockOptions | |
| public Session. | buildLockRequest(LockOptions
contains the lock level lockOptions)Implements org.
Deprecated
Build a new lock request that specifies:
|
| public <T> IdentifierLoadAccessImpl | byId(String
the entity name of the entity type to be retrieved entityName)Implements org. IdentifierLoadAccess instance to retrieve an instance of the named
entity type by its primary key.
|
| public <T> IdentifierLoadAccessImpl | byId(Class<T>
the entity type to be retrieved entityClass)Implements org. IdentifierLoadAccess instance to retrieve an instance of the given
entity type by its primary key.
|
| public <T> MultiIdentifierLoadAccess | byMultipleIds(Class<T>
the entity type to be retrieved entityClass)Implements org. MultiIdentifierLoadAccess instance to retrieve multiple instances
of the given entity type by their primary key values, using batching.
|
| public <T> MultiIdentifierLoadAccess | byMultipleIds(String
the entity name of the entity type to be retrieved entityName)Implements org. MultiIdentifierLoadAccess instance to retrieve multiple instances
of the named entity type by their primary key values, using batching.
|
| public <T> NaturalIdMultiLoadAccess | byMultipleNaturalId(Class<T>
the entity type to be retrieved entityClass)Implements org. MultiIdentifierLoadAccess instance to retrieve multiple instances
of the given entity type by their by natural id values, using batching.
|
| public <T> NaturalIdMultiLoadAccess | byMultipleNaturalId(String
the entity name of the entity type to be retrieved entityName)Implements org. MultiIdentifierLoadAccess instance to retrieve multiple instances
of the named entity type by their by natural id values, using batching.
|
| public <T> NaturalIdLoadAccess | byNaturalId(String
the entity name of the entity type to be retrieved entityName)Implements org. NaturalIdLoadAccess instance to retrieve an instance of the named
entity type by its natural id,
which may be a composite natural id. The entity must have at least one attribute
annotated org..
|
| public <T> NaturalIdLoadAccess | byNaturalId(Class<T>
the entity type to be retrieved entityClass)Implements org. NaturalIdLoadAccess instance to retrieve an instance of the given
entity type by its natural id,
which may be a composite natural id. The entity must have at least one attribute
annotated org..
|
| public <T> SimpleNaturalIdLoadAccess | bySimpleNaturalId(String
the entity name of the entity type to be retrieved entityName)Implements org. SimpleNaturalIdLoadAccess instance to retrieve an instance of the
named entity type by its natural id,
which must be a simple (non-composite) value.
|
| public <T> SimpleNaturalIdLoadAccess | bySimpleNaturalId(Class<T>
the entity type to be retrieved entityClass)Implements org. SimpleNaturalIdLoadAccess instance to retrieve an instance of the
given entity type by its natural id,
which must be a simple (non-composite) value.
|
| public void | cancelQuery()
Implements org. |
| protected void | |
| protected void | |
| public void | checkOpenOrWaitingForAutoClose()
Overrides org. Implements org. |
| protected void | |
| private void | |
| private void | |
| protected void | cleanupOnClose()
Overrides org. |
| public void | |
| public void | close()
Overrides org. Implements org. |
| public void | |
| private Map | |
| public boolean | contains(Object
entity instance object)Implements jakarta. |
| public boolean | contains(String
the entity name entityName, Object an instance of a persistent class object)Implements org. |
| protected ActionQueue | |
| private ClearEvent | |
| public ProcedureCall | createNamedStoredProcedureQuery(String
The name given to the template name)Overrides org. Implements org. ProcedureCall based on a named template
|
| protected StatefulPersistenceContext | |
| public ProcedureCall | createStoredProcedureCall(String
The name of the procedure. procedureName)Overrides org. Implements org. ProcedureCall to a stored procedure.
|
| public ProcedureCall | createStoredProcedureCall(String
The name of the procedure. procedureName, String... The explicit result set mapping(s) to use for mapping the results resultSetMappings)Overrides org. Implements org. ProcedureCall to a stored procedure with the given result
set entity mappings.
|
| public ProcedureCall | createStoredProcedureCall(String
The name of the procedure. procedureName, Class<?>... The entity(s) to map the result on to. resultClasses)Overrides org. Implements org. ProcedureCall to a stored procedure with the given result
set entity mappings.
|
| public ProcedureCall | createStoredProcedureQuery(String
The name of the procedure. procedureName)Overrides org. Implements org. ProcedureCall to a stored procedure.
|
| public ProcedureCall | createStoredProcedureQuery(String
The name of the procedure. procedureName, Class<T>... The entity(s) to map the result on to. resultClasses)Overrides org. Implements org. ProcedureCall to a stored procedure with the given result
set entity mappings.
|
| public ProcedureCall | createStoredProcedureQuery(String
The name of the procedure. procedureName, String... The explicit result set mapping(s) to use for mapping the results resultSetMappings)Overrides org. Implements org. ProcedureCall to a stored procedure with the given result set
entity mappings.
|
| public void | |
| public void | delete(Object
the instance to be removed object)Implements org.
Deprecated
Remove a persistent instance from the datastore.
|
| public void | delete(String
the entity name for the instance to be removed. entityName, Object the instance to be removed object)Implements org.
Deprecated
Remove a persistent instance from the datastore.
|
| public void | delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
Implements org. |
| public void | detach(Object
the managed instance to detach entity)Implements org. |
| protected CacheMode | |
| private static CacheRetrieveMode | |
| private static CacheStoreMode | |
| public void | disableFetchProfile(String
the name of the fetch profile to be disabled name)Implements org. fetch profile
with the given name in this session.
|
| public void | disableFilter(String
the name of the filter to be disabled. filterName)Implements org. |
| private void | |
| public void | enableFetchProfile(String
the name of the fetch profile to be enabled name)Implements org. fetch profile
with the given name in this session.
|
| public Filter | enableFilter(String
the name of the filter to be enabled. filterName)Implements org. |
| public void | evict(Object
the managed entity to evict object)Implements org. |
| public <T> T | find(Class<T>
entity class entityClass, Object primary key primaryKey)Implements jakarta. |
| public <T> T | |
| public <T> T | find(Class<T>
entity class entityClass, Object primary key primaryKey, LockModeType lock mode lockModeType)Implements jakarta. |
| public <T> T | find(Class<T>
entity class entityClass, Object primary key primaryKey, LockModeType lock mode lockModeType, Map<String, Object> standard and vendor-specific properties
and hints properties)Implements jakarta. |
| private void | |
| private void | |
| private void | |
| public void | fireLoad(LoadEvent event, LoadEventListener.
Implements org. |
| private void | |
| private void | |
| private void | |
| private void | |
| private Object | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private Object | |
| private void | |
| private void | |
| public void | flush()
Implements org. |
| public void | |
| public void | forceFlush(EntityEntry entityEntry)
Implements org. |
| public void | forceFlush(EntityKey key)
Implements org. |
| public <T> T | get(Class<T>
the entity type entityClass, Object an identifier id)Implements org. |
| public Object | get(String
the entity name entityName, Object an identifier id)Implements org. |
| public <T> T | get(Class<T>
the entity type entityClass, Object an identifier id, LockMode the lock mode lockMode)Implements org. |
| public <T> T | get(Class<T>
the entity type entityClass, Object an identifier id, LockOptions the lock mode lockOptions)Implements org. |
| public Object | get(String
the entity name entityName, Object an identifier id, LockMode the lock mode lockMode)Implements org. |
| public Object | get(String
the entity name entityName, Object an identifier id, LockOptions contains the lock mode lockOptions)Implements org. |
| public ActionQueue | getActionQueue()
Implements org. ActionQueue associated with this session.
|
| public CacheRetrieveMode | getCacheRetrieveMode()
Implements org. CacheRetrieveMode.
|
| public CacheStoreMode | getCacheStoreMode()
Implements org. CacheStoreMode.
|
| public Object | getContextEntityIdentifier(Object object)
Implements org. |
| public LockMode | getCurrentLockMode(Object
a persistent instance object)Implements org. LockMode of the given managed instance associated
with this session.
|
| public Object | getDelegate()
Implements jakarta. EntityManager,
if available.
|
| public Filter | getEnabledFilter(String
the name of the filter to be retrieved. filterName)Implements org. |
| public SessionFactoryImplementor | getEntityManagerFactory()
Implements jakarta.
Deprecated
as a consequence of
Return the entity manager factory for the entity manager.
SessionFactoryImplementor being deprecated.
|
| public String | getEntityName(Object
a persistent entity associated with this session object)Implements org. |
| public EntityPersister | |
| public Object | getEntityUsingInterceptor(EntityKey key)
Implements org. EntityKey,
calling the Interceptor if necessary.
|
| public int | getFetchBatchSize()
Implements org. |
| public Object | getIdentifier(Object
a persistent instance associated with this session object)Implements org. |
| private FlushMode | |
| public LoadQueryInfluencers | getLoadQueryInfluencers()
Implements org. LoadQueryInfluencers associated with this session.
|
| public LobHelper | getLobHelper()
Implements org. java.
and java..
|
| public LockModeType | getLockMode(Object
entity instance entity)Implements jakarta. |
| private LockOptions | |
| private LockOptions | |
| public Metamodel | getMetamodel()
Implements jakarta. Metamodel interface for access to the
metamodel of the persistence unit.
|
| public PersistenceContext | getPersistenceContext()
Implements org. |
| public PersistenceContext | getPersistenceContextInternal()
Implements org. getPersistenceContext(), with two differences:
|
| public Map | getProperties()
Implements jakarta. |
| private Boolean | |
| private static Boolean | |
| public <T> T | getReference(T
a detached persistent instance object)Implements org. |
| public <T> T | getReference(Class<T>
the entity type entityClass, Object the identifier of a persistent instance that exists in the database id)Implements org. |
| public Object | getReference(String
the entity name entityName, Object the identifier of a persistent instance that exists in the database id)Implements org. |
| public SessionImplementor | getSession()
Overrides default org. Implements org. WrapperOptions.
|
| public SessionFactoryImplementor | getSessionFactory()
Overrides default org. Implements org.
Deprecated
as a consequence of
Obtain the factory which created this session.
SessionFactoryImplementor being deprecated.
|
| private Object | |
| public SessionStatistics | |
| private Transaction | |
| public String | guessEntityName(Object object)
Implements org. org..
|
| public Object | immediateLoad(String entityName, Object id)
Implements org. |
| public void | initializeCollection(PersistentCollection<?> collection, boolean writing)
Implements org. |
| public Object | instantiate(String entityName, Object id)
Implements org. |
| public Object | instantiate(EntityPersister persister, Object id)
Implements org. |
| private void | |
| public Object | internalLoad(String entityName, Object id, boolean eager, boolean nullable)
Implements org. |
| protected static LoadEventListener. | |
| private void | |
| public boolean | isAutoCloseSessionEnabled()
Implements org. |
| public boolean | isDefaultReadOnly()
Implements org. |
| public boolean | isDirty()
Implements org. |
| public boolean | isEnforcingFetchGraph()
Overrides default org.
Deprecated
for removal.
Are we currently enforcing a fetch graph?
|
| public boolean | isEventSource()
Overrides default org. EventSource.
|
| public boolean | isFetchProfileEnabled(String
the name of the profile name)Implements org. fetch profile
with the given name enabled in this session?
|
| public boolean | isOpen()
Overrides org. Implements org. |
| public boolean | isReadOnly(Object
an entity or proxy entityOrProxy)Implements org. |
| public boolean | isSubselectFetchingEnabled()
Implements org. |
| private boolean | |
| private boolean | |
| public void | load(Object object, Object id)
Implements org. |
| public <T> T | load(Class<T>
a persistent class entityClass, Object a valid identifier of an existing persistent instance of the class id)Implements org.
Deprecated
Return the persistent instance of the given entity class with the given identifier,
making the assumption that the instance exists in the database.
|
| public Object | load(String
the entity name entityName, Object a valid identifier of an existing persistent instance of the class id)Implements abstract org. Implements org.
Deprecated
Return the persistent instance of the given entity class with the given identifier,
making the assumption that the instance exists in the database.
|
| public <T> T | load(Class<T>
a persistent class entityClass, Object a valid identifier of an existing persistent instance of the class id, LockMode the lock level lockMode)Implements org.
Deprecated
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
| public <T> T | load(Class<T>
a persistent class entityClass, Object a valid identifier of an existing persistent instance of the class id, LockOptions contains the lock level lockOptions)Implements org.
Deprecated
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
| public Object | load(String
the entity name entityName, Object a valid identifier of an existing persistent instance of the class id, LockMode the lock level lockMode)Implements org.
Deprecated
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
| public Object | load(String
the entity name entityName, Object a valid identifier of an existing persistent instance of the class id, LockOptions contains the lock level lockOptions)Implements org.
Deprecated
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
| public void | lock(Object
a persistent or transient instance object, LockOptions the lock options lockOptions)Implements org. lock options.
|
| public void | lock(String entityName, Object object, LockOptions lockOptions)
Implements org. |
| public void | lock(String
the name of the entity entityName, Object a persistent or transient instance object, LockMode the lock level lockMode)Implements org. |
| public void | lock(Object
a persistent or transient instance object, LockMode the lock level lockMode)Implements org. |
| public void | lock(Object
entity instance entity, LockModeType lock mode lockModeType)Implements jakarta. |
| public void | lock(Object
entity instance entity, LockModeType lock mode lockModeType, Map<String, Object> standard and vendor-specific properties
and hints properties)Implements jakarta. |
| private void | |
| private void | |
| private void | |
| public <T> T | merge(String
the entity name entityName, T a detached instance with state to be copied object)Implements org. |
| public <T> T | merge(T
a detached instance with state to be copied object)Implements org. |
| public void | merge(String entityName, Object object, MergeContext copiedAlready)
Implements org. |
| private boolean | |
| public void | persist(String
the entity name entityName, Object a transient instance to be made persistent object)Implements org. |
| public void | persist(Object
a transient instance to be made persistent object)Implements org. |
| public void | persist(String entityName, Object object, PersistContext copiedAlready)
Implements org. |
| public void | persistOnFlush(String entityName, Object object, PersistContext copiedAlready)
Implements org. |
| public void | pulseTransactionCoordinator()
Overrides org. Implements org. |
| private void | readObject(ObjectInputStream
The input stream from which we are being read... ois)Hides org. |
| private LoadEvent | recycleEventInstance(final LoadEvent event, final Object id, final String entityName)
Helper to avoid creating many new instances of LoadEvent: it's an allocation hot spot. |
| public void | refresh(Object
a persistent or detached instance object)Implements org. |
| public void | refresh(String
the name of the entity entityName, Object a persistent or detached instance object)Implements org.
Deprecated
Reread the state of the given managed instance associated with this session
from the underlying database.
|
| public void | refresh(Object
a persistent or detached instance object, LockMode the lock mode to use lockMode)Implements org. LockMode.
|
| public void | refresh(Object
a persistent or detached instance object, LockOptions contains the lock mode to use lockOptions)Implements org. LockMode.
|
| public void | refresh(String
the name of the entity entityName, Object a persistent or detached instance object, LockOptions contains the lock mode to use lockOptions)Implements org.
Deprecated
Reread the state of the given managed instance from the underlying database,
obtaining the given LockMode.
|
| public void | refresh(String entityName, Object object, RefreshContext refreshedAlready)
Implements org. |
| public void | refresh(Object
entity instance entity, Map<String, Object> standard and vendor-specific properties
and hints properties)Implements jakarta. |
| public void | refresh(Object
entity instance entity, LockModeType lock mode lockModeType)Implements jakarta. |
| public void | refresh(Object
entity instance entity, LockModeType lock mode lockModeType, Map<String, Object> standard and vendor-specific properties
and hints properties)Implements jakarta. |
| public void | remove(Object
the managed persistent instance to remove entity)Implements org. |
| public void | removeOrphanBeforeUpdates(String entityName, Object child)
Implements org. |
| protected void | |
| public void | replicate(Object
a detached instance of a persistent class obj, ReplicationMode the replication mode to use replicationMode)Implements org.
Deprecated
as a consequence of
Persist the state of the given detached instance, reusing the current
identifier value.
ReplicationMode being deprecated.
|
| public void | replicate(String
the entity name entityName, Object a detached instance of a persistent class obj, ReplicationMode the replication mode to use replicationMode)Implements org.
Deprecated
as a consequence of
Persist the state of the given detached instance, reusing the current
identifier value.
ReplicationMode being deprecated.
|
| private EntityPersister | |
| private EntityPersister | |
| public Object | save(Object
a transient instance of a persistent class obj)Implements org.
Deprecated
Persist the given transient instance, first assigning a generated identifier.
|
| public Object | save(String
the entity name entityName, Object a transient instance of a persistent class object)Implements org.
Deprecated
Persist the given transient instance, first assigning a generated identifier.
|
| public void | saveOrUpdate(Object
a transient or detached instance containing new or updated state object)Implements org.
Deprecated
Either save(Object) or update(Object) the given
instance, depending upon resolution of the unsaved-value checks (see the
manual for discussion of unsaved-value checking).
|
| public void | saveOrUpdate(String
the entity name entityName, Object a transient or detached instance containing new or updated state obj)Implements org.
Deprecated
Either save(String, Object) or update(String, Object)
the given instance, depending upon resolution of the unsaved-value checks
(see the manual for discussion of unsaved-value checking).
|
| public SharedSessionBuilder | sessionWithOptions()
Implements org. Session builder with the ability to copy certain information
from this session.
|
| public void | setAutoClear(boolean enabled)
Implements org. |
| public void | setCacheRetrieveMode(CacheRetrieveMode
a JPA-defined cacheRetrieveMode)CacheRetrieveModeImplements org. |
| public void | setCacheStoreMode(CacheStoreMode
a JPA-defined cacheStoreMode)CacheStoreModeImplements org. |
| public void | setDefaultReadOnly(boolean
true, the default for loaded entities/proxies is read-only;
false, the default for loaded entities/proxies is modifiableImplements org. |
| public void | setEnforcingFetchGraph(boolean isEnforcingFetchGraph)
Overrides default org.
Deprecated
for removal.
Enable or disable fetch graph enforcement.
|
| public void | setFetchBatchSize(int
the maximum batch size for batch fetching batchSize)Implements org. |
| public void | setFlushMode(FlushModeType
the new flushModeType)FlushModeTypeImplements org. JPA flush mode for this session.
|
| public void | setProperty(String
name of property or hint propertyName, Object value for property or hint value)Implements jakarta. |
| public void | setReadOnly(Object
an entity or proxy entity, boolean true if the entity or proxy should be made read-only;
false if the entity or proxy should be made modifiableImplements org. |
| public void | setSubselectFetchingEnabled(boolean
true to enable subselect fetchingImplements org. |
| public boolean | shouldAutoClose()
Implements org. |
| protected boolean | shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
Overrides org. |
| public void | startTransactionBoundary()
Overrides org. Implements org. org. API or via registration
of Hibernate's JTA Synchronization impl with a JTA Transaction
|
| private void | |
| public String | |
| public <T> T | unwrap(Class<T>
the class of the object to be returned. This is
normally either the underlying clazz)EntityManager implementation
class or an interface that it implements.Implements jakarta. |
| public void | update(Object
a detached instance containing updated state obj)Implements org.
Deprecated
Update the persistent instance with the identifier of the given detached
instance.
|
| public void | update(String
the entity name entityName, Object a detached instance containing updated state object)Implements org.
Deprecated
Update the persistent instance with the identifier of the given detached
instance.
|
| private void | writeObject(ObjectOutputStream
The output stream to which we are being written... oos)Hides org. |