Deprecated
as a consequence of HibernateEntityManager being deprecated. See corresponding docs for further information.
Session sess = factory.openSession();
Transaction tx;
try {
tx = sess.beginTransaction();
//do some work
...
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}
SessionFactory
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Session.LockRequest
Contains locking details (LockMode, Timeout and Scope). |
| Modifier and Type | Method and Description |
|---|---|
| public void | addEventListeners(SessionEventListener...
The listener(s) to add listeners)Add one or more listeners to the Session |
| public Session. | Returns: a lockRequest that can be used to lock the passed object.contains the lock level lockOptions)Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope. |
| public IdentifierLoadAccess | Returns: load delegate for loading the specified entity type by primary keyThe entity name of the entity type to be retrieved entityName)Create an |
| public <T> IdentifierLoadAccess | Returns: load delegate for loading the specified entity type by primary keyThe entity type to be retrieved entityClass)Create an |
| public <T> MultiIdentifierLoadAccess | Returns: load delegate for loading the specified entity type by primary key valuesThe entity type to be retrieved entityClass)Create a |
| public MultiIdentifierLoadAccess | Returns: load delegate for loading the specified entity type by primary key valuesThe entity name of the entity type to be retrieved entityName)Create a |
| public NaturalIdLoadAccess | Returns: load delegate for loading the specified entity type by natural idThe entity name of the entity type to be retrieved entityName)Create a |
| public <T> NaturalIdLoadAccess | Returns: load delegate for loading the specified entity type by natural idThe entity type to be retrieved entityClass)Create a |
| public SimpleNaturalIdLoadAccess | Returns: load delegate for loading the specified entity type by natural idThe entity name of the entity type to be retrieved entityName)Create a |
| public <T> SimpleNaturalIdLoadAccess | Returns: load delegate for loading the specified entity type by natural idThe entity type to be retrieved entityClass)Create a |
| public void | |
| public void | |
| public boolean | |
| public <T> RootGraph | createEntityGraph(Class<T>
class of entity graph rootType)Redeclares javax. |
| public RootGraph | createEntityGraph(String
name of an entity graph graphName)Redeclares javax. |
| public Query | Returns: The query instance for manipulation and executiona persistent collection collection, String a Hibernate query fragment. queryString)
Deprecated
(since 5.3) with no real replacement.
Create a Query instance for the given collection and filter string.
|
| public <T> Query | createNamedQuery(String
the name of a query defined in metadata name, Class<T> the type of the query result resultType)Redeclares org.
Deprecated
as a consequence of
Create an instance of Query being deprecated.
TypedQuery for executing a
Java Persistence query language named query.
|
| public <T> Query | createQuery(String
a Java Persistence query string queryString, Class<T> the type of the query result resultType)Redeclares org.
Deprecated
as a consequence of
Create an instance of Query being deprecated.
TypedQuery for executing a
Java Persistence query language statement.
|
| public <T> Query | createQuery(CriteriaQuery<T>
a criteria query object criteriaQuery)Redeclares org.
Deprecated
as a consequence of
Create an instance of Query being deprecated.
TypedQuery for executing a
criteria query.
|
| public Query | createQuery(CriteriaUpdate<T>
a criteria update query object updateQuery)Redeclares org.
Deprecated
as a consequence of
Create an instance of Query being deprecated.
Query for executing a criteria
update query.
|
| public Query | createQuery(CriteriaDelete<T>
a criteria delete query object deleteQuery)Redeclares org.
Deprecated
as a consequence of
Create an instance of Query being deprecated.
Query for executing a criteria
delete query.
|
| public NativeQuery | Returns: The query instance for manipulation and executionThe SQL query queryString)Redeclares as abstract: org.
Deprecated
(since 5.2) use
Create a createNativeQuery(String) instead
NativeQuery instance for the given SQL query string.
|
| public void | |
| public void | |
| public void | disableFetchProfile(String
The name of the fetch profile to be disabled. name)Disable a particular fetch profile on this session. |
| public void | disableFilter(String
The name of the filter to be disabled. filterName)Disable the named filter for the current session. |
| public Connection | Returns: the application-supplied connection ornullDisconnect the session from its underlying JDBC connection. |
| public void | enableFetchProfile(String
The name of the fetch profile to be enabled. name)Enable a particular fetch profile on this session. |
| public Filter | Returns: The Filter instance representing the enabled filter.The name of the filter to be enabled. filterName)Enable the named filter for this current session. |
| public void | |
| public void | |
| public <T> T | Returns: a persistent instance or nullThe entity type entityType, Serializable 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 nullThe entity type entityType, Serializable 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 nullThe entity type entityType, Serializable 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 nullthe entity name entityName, Serializable 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 nullthe entity name entityName, Serializable 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 nullthe entity name entityName, Serializable 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 | |
| public LockMode | Returns: the current lock modea persistent instance object)Determine the current lock mode of the given object. |
| public Filter | Returns: The Filter instance representing the enabled filter.The name of the filter to be retrieved. filterName)Retrieve a currently enabled filter by name. |
| public RootGraph | getEntityGraph(String
name of an existing entity graph graphName)Redeclares javax. |
| public default <T> List | getEntityGraphs(Class<T>
entity class entityClass)Implements javax. |
| public String | Returns: the entity namea persistent entity object)Return the entity name for a persistent entity. |
| public FlushModeType | Returns: The FlushModeType in effect for this Session.Redeclares javax. |
| public FlushMode | |
| public Serializable | Returns: the identifiera persistent instance object)Return the identifier value of the given entity as associated with this session. |
| public LobHelper | Returns: This session's LOB helperRetrieve this session's helper/delegate for creating LOB instances. |
| public default <T> T | Returns: the persistent instance or proxya 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.
Deprecated
as a consequence of
Get the session factory which created this session.
SessionFactory being deprecated.
|
| public SessionStatistics | Returns: The session statistics being collected for this sessionGet the statistics for this session. |
| public TypeHelper | |
| public boolean | Returns: true, loaded entities/proxies will be made read-only by default; false, loaded entities/proxies will be made modifiable by default.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.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.The name of the profile to be checked. name)Is a particular fetch profile enabled on this session? |
| public boolean | Returns: true if the entity or proxy is read-only, false if the entity or proxy is modifiable.an entity or HibernateProxy entityOrProxy)Is the specified entity or proxy read-only? |
| public <T> T | Returns: the persistent instance or proxya persistent class theClass, Serializable a valid identifier of an existing persistent instance of the class id, LockMode the lock level 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 proxya persistent class theClass, Serializable a valid identifier of an existing persistent instance of the class id, LockOptions contains the lock level 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 proxya persistent class entityName, Serializable a valid identifier of an existing persistent instance of the class id, LockMode the lock level 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 proxya persistent class entityName, Serializable a valid identifier of an existing persistent instance of the class id, LockOptions contains the lock level 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 proxya persistent class theClass, Serializable a valid identifier of an existing persistent instance of the class id)Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists. |
| public Object | Returns: the persistent instance or proxya persistent class entityName, Serializable a valid identifier of an existing persistent instance of the class id)Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists. |
| public void | load(Object
an "empty" instance of the persistent class object, Serializable a valid identifier of an existing persistent instance of the class id)Read the persistent state associated with the given identifier into the given transient instance. |
| public void | |
| public void | |
| public Object | Returns: an updated persistent instancea detached instance with state to be copied object)Redeclares javax. |
| public Object | |
| public void | persist(Object
a transient instance to be made persistent object)Redeclares javax. |
| public void | |
| public void | |
| public void | refresh(Object
a persistent or detached instance object)Redeclares javax. |
| public void | |
| public void | |
| public void | refresh(Object
a persistent or detached instance object, LockOptions contains the lock mode to use lockOptions)Re-read the state of the given instance from the underlying database, with the given LockMode. |
| public void | refresh(String
a persistent class entityName, Object a persistent or detached instance object, LockOptions contains the lock mode to use lockOptions)Re-read the state of the given instance from the underlying database, with the given LockMode. |
| public void | replicate(Object
a detached instance of a persistent class object, ReplicationMode The replication mode to use replicationMode)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)Persist the state of the given detached instance, reusing the current identifier value. |
| public Serializable | |
| public Serializable | |
| public void | saveOrUpdate(Object
a transient or detached instance containing new or updated state object)Either |
| public void | saveOrUpdate(String
The entity name entityName, Object a transient or detached instance containing new or updated state object)Either |
| public SharedSessionBuilder | Returns: The session builderObtain a |
| public void | |
| 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 | setFlushMode(FlushMode
the new flush mode flushMode)
Deprecated
(since 5.2) use
Set the flush mode for this session.
setHibernateFlushMode(FlushMode) instead
|
| public void | |
| public void | setReadOnly(Object
an entity or HibernateProxy entityOrProxy, boolean true if the entity or proxy should be made read-only; false if the entity or
proxy should be made modifiableSet an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. |
| public void | |
| public void |