Top Description Inners Methods
org.hibernate

public Interface Session

extends SharedSessionContract, EntityManager
Known Direct Subinterfaces
org.hibernate.engine.spi.SessionImplementor
Known Direct Implementers
org.hibernate.engine.spi.SessionLazyDelegator
Imports
java.util.List, java.util.function.Consumer, jakarta.persistence.CacheRetrieveMode, .CacheStoreMode, .PessimisticLockScope, .EntityGraph, .EntityManager, .FlushModeType, org.hibernate.graph.RootGraph, org.hibernate.jdbc.Work, org.hibernate.query.Query, org.hibernate.stat.SessionStatistics, jakarta.persistence.criteria.CriteriaDelete, .CriteriaQuery, .CriteriaUpdate

The main runtime interface between a Java application and Hibernate. Represents the notion of a persistence context, a set of managed entity instances associated with a logical transaction.

The lifecycle of a Session is bounded by the beginning and end of the logical transaction. But a long logical transaction might span several database transactions.

The primary purpose of the Session is to offer create, read, and delete operations for instances of mapped entity classes. An instance may be in one of three states with respect to a given open session:

At any given time, an instance may be associated with at most one open session.

Any instance returned by get(Class, Object) or by a query is persistent.

A transient instance may be made persistent by calling persist(Object). A persistent instance may be made detached by calling detach(Object). A persistent instance may be marked for removal, and eventually made transient, by calling remove(Object).

Persistent instances are held in a managed state by the persistence context. Any change to the state of a persistent instance is automatically detected and eventually flushed to the database. This process of automatic change detection is called dirty checking and can be expensive in some circumstances. Dirty checking may be disabled by marking an entity as read-only using setReadOnly(Object, boolean) or simply by evicting it from the persistence context. A session may be set to load entities as read-only by default, or this may be controlled at the query level.

The state of a transient or detached instance may be made persistent by copying it to a persistent instance using merge(Object). All older operations which moved a detached instance to the persistent state are now deprecated, and clients should now migrate to the use of merge().

From time to time, a flush operation is triggered, and the session synchronizes state held in memory with persistent state held in the database by executing SQL insert, update, and delete statements. Note that SQL statements are often not executed synchronously by the methods of the Session interface. If synchronous execution of SQL is desired, the StatelessSession allows this.

A persistence context holds hard references to all its entities and prevents them from being garbage collected. Therefore, a Session is a short-lived object, and must be discarded as soon as a logical transaction ends. In extreme cases, clear() and detach(Object) may be used to control memory usage. However, for processes which read many entities, a StatelessSession should be used.

A session might be associated with a container-managed JTA transaction, or it might be in control of its own resource-local database transaction. In the case of a resource-local transaction, the client must demarcate the beginning and end of the transaction using a Transaction. A typical resource-local transaction should use the following idiom:

Session session = factory.openSession();
Transaction tx = null;
try {
    tx = session.beginTransaction();
    //do some work
    ...
    tx.commit();
}
catch (Exception e) {
    if (tx!=null) tx.rollback();
    throw e;
}
finally {
    session.close();
}

It's crucially important to appreciate the following restrictions and why they exist:

An easy way to be sure that session and transaction management is being done correctly is to let the factory do it:

sessionFactory.inTransaction(session -> {
    //do the work
    ...
});

A session may be used to execute JDBC work using its JDBC connection and transaction:

session.doWork(connection -> {
    try ( PreparedStatement ps = connection.prepareStatement( " ... " ) ) {
        ps.execute();
    }
});

A Session instance is serializable if its entities are serializable.

Every Session is a JPA EntityManager. Furthermore, when Hibernate is acting as the JPA persistence provider, the method EntityManager#unwrap(Class) may be used to obtain the underlying Session.

Hibernate, unlike JPA, allows a persistence unit where an entity class is mapped multiple times, with different entity names, usually to different tables. In this case, the session needs a way to identify the entity name of a given instance of the entity class. Therefore, some operations of this interface, including operations inherited from EntityManager, are overloaded with a form that accepts an explicit entity name along with the instance. An alternative solution to this problem is to provide an EntityNameResolver.

Authors
Gavin King, Steve Ebersole
See Also
SessionFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Session.LockRequest

Deprecated since 6.2. simply construct a LockOptions and pass it to lock(Object, LockOptions).
A set of locking options attached to the session.

Method Summary

Modifier and TypeMethod and Description
public void
addEventListeners(SessionEventListener...
the listener(s) to add
listeners
)

Add one or more listeners to the Session

public Session.LockRequest

Returns:

a LockRequest that can be used to lock any given object.
buildLockRequest
(LockOptions
contains the lock level
lockOptions
)

Deprecated since 6.2. use lock(Object, LockOptions)
Build a new lock request that specifies:
public <T> IdentifierLoadAccess<T>

Returns:

an instance of IdentifierLoadAccess for executing the lookup
byId
(Class<T>
the entity type to be retrieved
entityClass
)

Create an IdentifierLoadAccess instance to retrieve an instance of the given entity type by its primary key.

public <T> IdentifierLoadAccess<T>

Returns:

an instance of IdentifierLoadAccess for executing the lookup
byId
(String
the entity name of the entity type to be retrieved
entityName
)

Create an IdentifierLoadAccess instance to retrieve an instance of the named entity type by its primary key.

public <T> MultiIdentifierLoadAccess<T>

Returns:

an instance of MultiIdentifierLoadAccess for executing the lookup
byMultipleIds
(Class<T>
the entity type to be retrieved
entityClass
)

Create a MultiIdentifierLoadAccess instance to retrieve multiple instances of the given entity type by their primary key values, using batching.

public <T> MultiIdentifierLoadAccess<T>

Returns:

an instance of MultiIdentifierLoadAccess for executing the lookup
byMultipleIds
(String
the entity name of the entity type to be retrieved
entityName
)

Create a MultiIdentifierLoadAccess instance to retrieve multiple instances of the named entity type by their primary key values, using batching.

public <T> NaturalIdMultiLoadAccess<T>

Returns:

an instance of NaturalIdMultiLoadAccess for executing the lookup
byMultipleNaturalId
(Class<T>
the entity type to be retrieved
entityClass
)

Create a MultiIdentifierLoadAccess instance to retrieve multiple instances of the given entity type by their by natural id values, using batching.

public <T> NaturalIdMultiLoadAccess<T>

Returns:

an instance of NaturalIdMultiLoadAccess for executing the lookup
byMultipleNaturalId
(String
the entity name of the entity type to be retrieved
entityName
)

Create a MultiIdentifierLoadAccess instance to retrieve multiple instances of the named entity type by their by natural id values, using batching.

public <T> NaturalIdLoadAccess<T>

Returns:

an instance of NaturalIdLoadAccess for executing the lookup
byNaturalId
(Class<T>
the entity type to be retrieved
entityClass
)

Create a 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.hibernate.annotations.NaturalId.

public <T> NaturalIdLoadAccess<T>

Returns:

an instance of NaturalIdLoadAccess for executing the lookup
byNaturalId
(String
the entity name of the entity type to be retrieved
entityName
)

Create a 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.hibernate.annotations.NaturalId.

public <T> SimpleNaturalIdLoadAccess<T>

Returns:

an instance of SimpleNaturalIdLoadAccess for executing the lookup
bySimpleNaturalId
(Class<T>
the entity type to be retrieved
entityClass
)

Create a SimpleNaturalIdLoadAccess instance to retrieve an instance of the given entity type by its natural id, which must be a simple (non-composite) value.

public <T> SimpleNaturalIdLoadAccess<T>

Returns:

an instance of SimpleNaturalIdLoadAccess for executing the lookup
bySimpleNaturalId
(String
the entity name of the entity type to be retrieved
entityName
)

Create a SimpleNaturalIdLoadAccess instance to retrieve an instance of the named entity type by its natural id, which must be a simple (non-composite) value.

public void
cancelQuery()

Cancel the execution of the current query.

public void
clear()

Redeclares jakarta.persistence.EntityManager.clear.

Completely clear the session.
public boolean

Returns:

true if the given instance is associated with this Session
contains
(String
the entity name
entityName
,
Object
an instance of a persistent class
object
)

Determine if the given entity is associated with this session.

public <T> RootGraph<T>
createEntityGraph(Class<T>
the root entity class of the graph
rootType
)

Redeclares org.hibernate.SharedSessionContract.createEntityGraph, jakarta.persistence.EntityManager.createEntityGraph.

Create a new mutable EntityGraph with only a root node.
public RootGraph<?>
createEntityGraph(String
the name of the graph
graphName
)

Redeclares org.hibernate.SharedSessionContract.createEntityGraph, jakarta.persistence.EntityManager.createEntityGraph.

Create a new mutable copy of the named EntityGraph, or return null if there is no graph with the given name.
public <R> Query<R>
createNamedQuery(String
the name of a query defined in metadata
name
,
Class<R>
the type of the query result
resultClass
)

Redeclares org.hibernate.query.QueryProducer.createNamedQuery, jakarta.persistence.EntityManager.createNamedQuery.

Create an instance of TypedQuery for executing a Jakarta Persistence query language named query.
public Query<R>
createNamedQuery(String
the name of a query defined in metadata
name
)

Redeclares org.hibernate.query.QueryProducer.createNamedQuery, jakarta.persistence.EntityManager.createNamedQuery.

Deprecated
Create an instance of Query for executing a named query (in the Jakarta Persistence query language or in native SQL).
public <R> Query<R>
createQuery(String
a Jakarta Persistence query string
queryString
,
Class<R>
the type of the query result
resultClass
)

Redeclares org.hibernate.query.QueryProducer.createQuery, jakarta.persistence.EntityManager.createQuery.

Create an instance of TypedQuery for executing a Jakarta Persistence query language statement.
public Query<R>
createQuery(String
a Jakarta Persistence query string
queryString
)

Redeclares org.hibernate.query.QueryProducer.createQuery, jakarta.persistence.EntityManager.createQuery.

Deprecated
Create an instance of Query for executing a Jakarta Persistence query language statement.
public <R> Query<R>
createQuery(CriteriaQuery<R>
a criteria query object
criteriaQuery
)

Redeclares org.hibernate.query.QueryProducer.createQuery, jakarta.persistence.EntityManager.createQuery.

Create an instance of TypedQuery for executing a criteria query.
public Query<R>
createQuery(CriteriaDelete<T>
a criteria delete query object
deleteQuery
)

Redeclares org.hibernate.query.QueryProducer.createQuery, jakarta.persistence.EntityManager.createQuery.

Deprecated since 6.0. use createMutationQuery(CriteriaDelete)
Create a Query for the given JPA CriteriaDelete.
public Query<R>
createQuery(CriteriaUpdate<T>
a criteria update query object
updateQuery
)

Redeclares org.hibernate.query.QueryProducer.createQuery, jakarta.persistence.EntityManager.createQuery.

Deprecated since 6.0. use createMutationQuery(CriteriaUpdate)
Create a Query for the given JPA CriteriaUpdate.
public void
delete(Object
the instance to be removed
object
)

Deprecated since 6.0. use remove(Object)
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
)

Deprecated since 6.0. use remove(Object)
Remove a persistent instance from the datastore.
public void
detach(Object
the managed instance to detach
object
)

Redeclares jakarta.persistence.EntityManager.detach.

Remove this instance from the session cache.
public void
disableFetchProfile(String
the name of the fetch profile to be disabled
name
)

Disable the fetch profile with the given name in this session.

public void
disableFilter(String
the name of the filter to be disabled.
filterName
)

Disable the named filter for the current session.

public void
enableFetchProfile(String
the name of the fetch profile to be enabled
name
)

Enable the fetch profile with the given name in this session.

public Filter

Returns:

the Filter instance representing the enabled filter.
enableFilter
(String
the name of the filter to be enabled.
filterName
)

Enable the named filter for this current session.

public void
evict(Object
the managed entity to evict
object
)

Remove this instance from the session cache.

public void
flush()

Redeclares jakarta.persistence.EntityManager.flush.

Force this session to flush.
public <T> T

Returns:

a persistent instance or null
get
(Class<T>
the entity type
entityType
,
Object
an identifier
id
)

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.

public <T> T

Returns:

a persistent instance or null
get
(Class<T>
the entity type
entityType
,
Object
an identifier
id
,
LockMode
the lock mode
lockMode
)

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.

public <T> T

Returns:

a persistent instance or null
get
(Class<T>
the entity type
entityType
,
Object
an identifier
id
,
LockOptions
the lock mode
lockOptions
)

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.

public Object

Returns:

a persistent instance or null
get
(String
the entity name
entityName
,
Object
an identifier
id
)

Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.

public Object

Returns:

a persistent instance or null
get
(String
the entity name
entityName
,
Object
an identifier
id
,
LockMode
the lock mode
lockMode
)

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.

public Object

Returns:

a persistent instance or null
get
(String
the entity name
entityName
,
Object
an identifier
id
,
LockOptions
contains the lock mode
lockOptions
)

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.

public CacheMode

Returns:

the current cache mode
getCacheMode
()

Get the current cache mode for this session.

public CacheRetrieveMode
public CacheStoreMode
public LockMode

Returns:

the current lock mode
getCurrentLockMode
(Object
a persistent instance
object
)

Determine the current LockMode of the given managed instance associated with this session.

public Filter

Returns:

the Filter instance representing the enabled filter.
getEnabledFilter
(String
the name of the filter to be retrieved.
filterName
)

Retrieve a currently enabled filter by name.

public RootGraph<?>
getEntityGraph(String
the name of the graph
graphName
)

Redeclares org.hibernate.SharedSessionContract.getEntityGraph, jakarta.persistence.EntityManager.getEntityGraph.

Retrieve the named EntityGraph as an immutable graph, or return null if there is no graph with the given name.
public <T> List<EntityGraph<? super T>>
public String

Returns:

the entity name
getEntityName
(Object
a persistent entity associated with this session
object
)

Return the entity name for a persistent entity.

public int
getFetchBatchSize()

Get the maximum batch size for batch fetching associations by id in this session.

public FlushModeType

Returns:

the FlushModeType currently in effect
getFlushMode
()

Redeclares jakarta.persistence.EntityManager.getFlushMode.

Get the current JPA flush mode for this session.
public FlushMode

Returns:

the FlushMode currently in effect
getHibernateFlushMode
()

Get the current flush mode for this session.

public Object

Returns:

the identifier
getIdentifier
(Object
a persistent instance associated with this session
object
)

Return the identifier value of the given entity associated with this session.

public LobHelper

Returns:

an instance of LobHelper
getLobHelper
()

Obtain a factory for instances of java.sql.Blob and java.sql.Clob.

public <T> T

Returns:

the persistent instance or proxy
getReference
(Class<T>
the entity type
entityType
,
Object
the identifier of a persistent instance that exists in the database
id
)

Redeclares jakarta.persistence.EntityManager.getReference.

Return a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database.
public Object

Returns:

the persistent instance or proxy
getReference
(String
the entity name
entityName
,
Object
the identifier of a persistent instance that exists in the database
id
)

Return a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database.

public <T> T

Returns:

the persistent instance or proxy
getReference
(T
a detached persistent instance
object
)

Return a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database.

public SessionFactory

Returns:

the session factory
getSessionFactory
()

Get the session factory which created this session.

public SessionStatistics

Returns:

the session statistics being collected for this session
getStatistics
()

Get the statistics for this session.

public boolean

Returns:

true, loaded entities/proxies will be made read-only by default; false, loaded entities/proxies will be made modifiable by default.
isDefaultReadOnly
()

Will entities and proxies that are loaded into this session be made read-only by default?

public boolean

Returns:

true if the session contains pending changes; false otherwise.
isDirty
()

Does this session contain any changes which must be synchronized with the database?

public boolean

Returns:

True if fetch profile is enabled; false if not.
isFetchProfileEnabled
(String
the name of the profile
name
)

Is the fetch profile with the given name enabled in this session?

public boolean

Returns:

true if the entity or proxy is read-only, false if the entity or proxy is modifiable.
isReadOnly
(Object
an entity or proxy
entityOrProxy
)

Is the specified entity or proxy read-only?

public boolean

Returns:

true is subselect fetching is enabled
isSubselectFetchingEnabled
()

Determine if subselect fetching is enabled in this session.

public <T> T

Returns:

the persistent instance or proxy
load
(Class<T>
a persistent class
theClass
,
Object
a valid identifier of an existing persistent instance of the class
id
,
LockMode
the lock level
lockMode
)

Deprecated since 6.0. use get(Class, Object, LockMode)
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

Returns:

the persistent instance or proxy
load
(Class<T>
a persistent class
theClass
,
Object
a valid identifier of an existing persistent instance of the class
id
,
LockOptions
contains the lock level
lockOptions
)

Deprecated since 6.0. use get(Class, Object, LockOptions)
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
public Object

Returns:

the persistent instance or proxy
load
(String
the entity name
entityName
,
Object
a valid identifier of an existing persistent instance of the class
id
,
LockMode
the lock level
lockMode
)

Deprecated since 6.0. use get(String, Object, LockMode)
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
public Object

Returns:

the persistent instance or proxy
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
)

Deprecated since 6.0. use get(String, Object, LockOptions)
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

Returns:

the persistent instance or proxy
load
(Class<T>
a persistent class
theClass
,
Object
a valid identifier of an existing persistent instance of the class
id
)

Deprecated since 6.0. use getReference(Class, Object)
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

Returns:

the persistent instance or proxy
load
(String
the entity name
entityName
,
Object
a valid identifier of an existing persistent instance of the class
id
)

Deprecated since 6.0. use getReference(String, Object)
Return the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database.
public void
load(Object object, Object id)

Read the persistent state associated with the given identifier into the given transient instance.

public void
lock(Object
a persistent or transient instance
object
,
LockMode
the lock level
lockMode
)

Obtain the specified lock level on the given managed instance associated with this session.

public void
lock(Object
a persistent or transient instance
object
,
LockOptions
the lock options
lockOptions
)

Obtain a lock on the given managed instance associated with this session, using the given lock options.

public void
lock(String
the name of the entity
entityName
,
Object
a persistent or transient instance
object
,
LockMode
the lock level
lockMode
)

Deprecated since 6.2. use lock(Object, LockMode)
Obtain the specified lock level on the given managed instance associated with this session.
public <T> T

Returns:

an updated persistent instance
merge
(T
a detached instance with state to be copied
object
)

Redeclares jakarta.persistence.EntityManager.merge.

Copy the state of the given object onto the persistent object with the same identifier.
public <T> T

Returns:

an updated persistent instance
merge
(String
the entity name
entityName
,
T
a detached instance with state to be copied
object
)

Copy the state of the given object onto the persistent object with the same identifier.

public void
persist(Object
a transient instance to be made persistent
object
)

Redeclares jakarta.persistence.EntityManager.persist.

Make a transient instance persistent and mark it for later insertion in the database.
public void
persist(String
the entity name
entityName
,
Object
a transient instance to be made persistent
object
)

Make a transient instance persistent and mark it for later insertion in the database.

public void
refresh(Object
a persistent or detached instance
object
)

Redeclares jakarta.persistence.EntityManager.refresh.

Reread the state of the given managed instance associated with this session from the underlying database.
public void
refresh(String
the name of the entity
entityName
,
Object
a persistent or detached instance
object
)

Deprecated since 6.0. use refresh(Object)
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
)

Reread the state of the given managed instance from the underlying database, obtaining the given LockMode.

public void
refresh(Object
a persistent or detached instance
object
,
LockOptions
contains the lock mode to use
lockOptions
)

Reread the state of the given managed instance from the underlying database, obtaining the given 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
)

Deprecated since 6.0. use refresh(Object, LockOptions)
Reread the state of the given managed instance from the underlying database, obtaining the given LockMode.
public void
remove(Object
the managed persistent instance to remove
object
)

Redeclares jakarta.persistence.EntityManager.remove.

Mark a persistence instance associated with this session for removal from the underlying database.
public void
replicate(Object
a detached instance of a persistent class
object
,
ReplicationMode
the replication mode to use
replicationMode
)

Deprecated since 6.0. With no real replacement
Persist the state of the given detached instance, reusing the current identifier value.
public void
replicate(String
the entity name
entityName
,
Object
a detached instance of a persistent class
object
,
ReplicationMode
the replication mode to use
replicationMode
)

Deprecated since 6.0. With no real replacement
Persist the state of the given detached instance, reusing the current identifier value.
public Object

Returns:

the generated identifier
save
(Object
a transient instance of a persistent class
object
)

Deprecated since 6.0. use persist(Object)
Persist the given transient instance, first assigning a generated identifier.
public Object

Returns:

the generated identifier
save
(String
the entity name
entityName
,
Object
a transient instance of a persistent class
object
)

Deprecated since 6.0. use persist(String, Object)
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
)

Deprecated since 6.0. use merge(String, Object) or persist(Object)
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
object
)

Deprecated since 6.0. use merge(String, Object) or persist(String, Object)
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

Returns:

the session builder
sessionWithOptions
()

Obtain a Session builder with the ability to copy certain information from this session.

public void
setCacheMode(CacheMode
the new cache mode
cacheMode
)

Set the current cache mode for this session.

public void
setCacheRetrieveMode(CacheRetrieveMode
a JPA-defined CacheRetrieveMode
cacheRetrieveMode
)

Enable or disable reads from the second-level cache.

public void
setCacheStoreMode(CacheStoreMode
a JPA-defined CacheStoreMode
cacheStoreMode
)

Enable or disable writes to the second-level cache.

public void
setDefaultReadOnly(boolean
true, the default for loaded entities/proxies is read-only; false, the default for loaded entities/proxies is modifiable
readOnly
)

Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.

public void
setFetchBatchSize(int
the maximum batch size for batch fetching
batchSize
)

Set the maximum batch size for batch fetching associations by id in this session.

public void
setFlushMode(FlushModeType flushMode)

Redeclares jakarta.persistence.EntityManager.setFlushMode.

Set the current JPA flush mode for this session.
public void
setHibernateFlushMode(FlushMode
the new FlushMode
flushMode
)

Set the current flush mode for this session.

public void
setReadOnly(Object
an entity or proxy
entityOrProxy
,
boolean
true if the entity or proxy should be made read-only; false if the entity or proxy should be made modifiable
readOnly
)

Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.

public void
setSubselectFetchingEnabled(boolean
true to enable subselect fetching
enabled
)

Enable or disable subselect fetching in this session.

public void
update(Object
a detached instance containing updated state
object
)

Deprecated since 6.0. use merge(Object)
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
)

Deprecated since 6.0. use merge(String, Object)
Update the persistent instance with the identifier of the given detached instance.
Inherited from jakarta.persistence.EntityManager:
closecontainscreateNamedStoredProcedureQuerycreateNativeQuerycreateNativeQuerycreateNativeQuerycreateStoredProcedureQuerycreateStoredProcedureQuerycreateStoredProcedureQueryfindfindfindfindgetCriteriaBuildergetDelegategetEntityManagerFactorygetLockModegetMetamodelgetPropertiesgetTransactionisJoinedToTransactionisOpenjoinTransactionlocklockrefreshrefreshrefreshsetPropertyunwrap
Inherited from org.hibernate.SharedSessionContract:
beginTransactionclosecreateEntityGraphcreateNamedStoredProcedureQuerycreateStoredProcedureCallcreateStoredProcedureCallcreateStoredProcedureCallcreateStoredProcedureQuerycreateStoredProcedureQuerycreateStoredProcedureQuerydoReturningWorkdoWorkgetCriteriaBuildergetFactorygetJdbcBatchSizegetNamedProcedureCallgetTenantIdentifiergetTenantIdentifierValuegetTransactionisConnectedisJoinedToTransactionisOpenjoinTransactionsetJdbcBatchSize