public interface Session extends SharedSessionContract, EntityManager, HibernateEntityManager, AutoCloseable, Closeable
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 | Interface and Description |
---|---|
static interface |
Session.LockRequest
Contains locking details (LockMode, Timeout and Scope).
|
Modifier and Type | Method and Description |
---|---|
void |
addEventListeners(SessionEventListener... listeners)
Add one or more listeners to the Session
|
Session.LockRequest |
buildLockRequest(LockOptions lockOptions)
Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.
|
<T> IdentifierLoadAccess<T> |
byId(Class<T> entityClass)
Create an
IdentifierLoadAccess instance to retrieve the specified entity by
primary key. |
IdentifierLoadAccess |
byId(String entityName)
Create an
IdentifierLoadAccess instance to retrieve the specified entity type by
primary key. |
<T> MultiIdentifierLoadAccess<T> |
byMultipleIds(Class<T> entityClass)
Create a
MultiIdentifierLoadAccess instance to retrieve multiple entities at once
as specified by primary key values. |
MultiIdentifierLoadAccess |
byMultipleIds(String entityName)
Create a
MultiIdentifierLoadAccess instance to retrieve multiple entities at once
as specified by primary key values. |
<T> NaturalIdLoadAccess<T> |
byNaturalId(Class<T> entityClass)
Create a
NaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
NaturalIdLoadAccess |
byNaturalId(String entityName)
Create a
NaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
<T> SimpleNaturalIdLoadAccess<T> |
bySimpleNaturalId(Class<T> entityClass)
Create a
SimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its simple (single attribute) natural id. |
SimpleNaturalIdLoadAccess |
bySimpleNaturalId(String entityName)
Create a
SimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
void |
cancelQuery()
Cancel the execution of the current query.
|
void |
clear()
Completely clear the session.
|
boolean |
contains(String entityName,
Object object)
Check if this entity is associated with this Session.
|
Query |
createFilter(Object collection,
String queryString)
Deprecated.
(since 5.3) with no real replacement.
|
<T> Query<T> |
createNamedQuery(String name,
Class<T> resultType)
The JPA-defined named, typed query creation method.
|
Query |
createQuery(CriteriaDelete deleteQuery)
Create an instance of
Query for executing a criteria
delete query. |
<T> Query<T> |
createQuery(CriteriaQuery<T> criteriaQuery)
Create an instance of
TypedQuery for executing a
criteria query. |
Query |
createQuery(CriteriaUpdate updateQuery)
Create an instance of
Query for executing a criteria
update query. |
Query |
createQuery(String queryString)
Create a
Query instance for the given HQL/JPQL query string. |
<T> Query<T> |
createQuery(String queryString,
Class<T> resultType)
Create a typed
Query instance for the given HQL/JPQL query string. |
NativeQuery |
createSQLQuery(String queryString)
Create a
NativeQuery instance for the given SQL query string. |
void |
delete(Object object)
Remove a persistent instance from the datastore.
|
void |
delete(String entityName,
Object object)
Remove a persistent instance from the datastore.
|
void |
disableFetchProfile(String name)
Disable a particular fetch profile on this session.
|
void |
disableFilter(String filterName)
Disable the named filter for the current session.
|
Connection |
disconnect()
Disconnect the session from its underlying JDBC connection.
|
<T> T |
doReturningWork(ReturningWork<T> work)
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.
|
void |
doWork(Work work)
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.
|
void |
enableFetchProfile(String name)
Enable a particular fetch profile on this session.
|
Filter |
enableFilter(String filterName)
Enable the named filter for this current session.
|
void |
evict(Object object)
Remove this instance from the session cache.
|
void |
flush()
Force this session to flush.
|
<T> T |
get(Class<T> entityType,
Serializable id)
Return the persistent instance of the given entity class with the given identifier,
or null if there is no such persistent instance.
|
<T> T |
get(Class<T> entityType,
Serializable id,
LockMode lockMode)
Return the persistent instance of the given entity class with the given identifier,
or null if there is no such persistent instance.
|
<T> T |
get(Class<T> entityType,
Serializable id,
LockOptions lockOptions)
Return the persistent instance of the given entity class with the given identifier,
or null if there is no such persistent instance.
|
Object |
get(String entityName,
Serializable id)
Return the persistent instance of the given named entity with the given identifier,
or null if there is no such persistent instance.
|
Object |
get(String entityName,
Serializable id,
LockMode lockMode)
Return the persistent instance of the given entity class with the given identifier,
or null if there is no such persistent instance.
|
Object |
get(String entityName,
Serializable id,
LockOptions lockOptions)
Return the persistent instance of the given entity class with the given identifier,
or null if there is no such persistent instance.
|
CacheMode |
getCacheMode()
Get the current cache mode.
|
LockMode |
getCurrentLockMode(Object object)
Determine the current lock mode of the given object.
|
Filter |
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.
|
String |
getEntityName(Object object)
Return the entity name for a persistent entity.
|
FlushModeType |
getFlushMode()
Get the flush mode that applies to all objects contained
in the persistence context.
|
FlushMode |
getHibernateFlushMode()
Get the current flush mode for this session.
|
Serializable |
getIdentifier(Object object)
Return the identifier value of the given entity as associated with this
session.
|
LobHelper |
getLobHelper()
Retrieve this session's helper/delegate for creating LOB instances.
|
Query |
getNamedQuery(String queryName)
Create a
Query instance for the named query. |
SessionFactory |
getSessionFactory()
Get the session factory which created this session.
|
SessionStatistics |
getStatistics()
Get the statistics for this session.
|
TypeHelper |
getTypeHelper()
Convenience access to the
TypeHelper associated with this session's SessionFactory . |
boolean |
isDefaultReadOnly()
Will entities and proxies that are loaded into this session be made
read-only by default?
To determine the read-only/modifiable setting for a particular entity
or proxy:
|
boolean |
isDirty()
Does this session contain any changes which must be synchronized with
the database? In other words, would any DML operations be executed if
we flushed this session?
|
boolean |
isFetchProfileEnabled(String name)
Is a particular fetch profile enabled on this session?
|
boolean |
isReadOnly(Object entityOrProxy)
Is the specified entity or proxy read-only?
To get the default read-only/modifiable setting used for
entities and proxies that are loaded into the session:
|
<T> T |
load(Class<T> theClass,
Serializable id)
Return the persistent instance of the given entity class with the given identifier,
assuming that the instance exists.
|
<T> T |
load(Class<T> theClass,
Serializable id,
LockMode lockMode)
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
<T> T |
load(Class<T> theClass,
Serializable id,
LockOptions lockOptions)
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
void |
load(Object object,
Serializable id)
Read the persistent state associated with the given identifier into the given transient
instance.
|
Object |
load(String entityName,
Serializable id)
Return the persistent instance of the given entity class with the given identifier,
assuming that the instance exists.
|
Object |
load(String entityName,
Serializable id,
LockMode lockMode)
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
Object |
load(String entityName,
Serializable id,
LockOptions lockOptions)
Return the persistent instance of the given entity class with the given identifier,
obtaining the specified lock mode, assuming the instance exists.
|
void |
lock(Object object,
LockMode lockMode)
Obtain the specified lock level upon the given object.
|
void |
lock(String entityName,
Object object,
LockMode lockMode)
Obtain the specified lock level upon the given object.
|
Object |
merge(Object object)
Copy the state of the given object onto the persistent object with the same
identifier.
|
Object |
merge(String entityName,
Object object)
Copy the state of the given object onto the persistent object with the same
identifier.
|
void |
persist(Object object)
Make a transient instance persistent.
|
void |
persist(String entityName,
Object object)
Make a transient instance persistent.
|
void |
reconnect(Connection connection)
Reconnect to the given JDBC connection.
|
void |
refresh(Object object)
Re-read the state of the given instance from the underlying database.
|
void |
refresh(Object object,
LockMode lockMode)
Re-read the state of the given instance from the underlying database, with
the given LockMode.
|
void |
refresh(Object object,
LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with
the given LockMode.
|
void |
refresh(String entityName,
Object object)
Re-read the state of the given instance from the underlying database.
|
void |
refresh(String entityName,
Object object,
LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with
the given LockMode.
|
void |
replicate(Object object,
ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current
identifier value.
|
void |
replicate(String entityName,
Object object,
ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current
identifier value.
|
Serializable |
save(Object object)
Persist the given transient instance, first assigning a generated identifier.
|
Serializable |
save(String entityName,
Object object)
Persist the given transient instance, first assigning a generated identifier.
|
void |
saveOrUpdate(Object 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). |
void |
saveOrUpdate(String entityName,
Object 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). |
SharedSessionBuilder |
sessionWithOptions()
Obtain a
Session builder with the ability to grab certain information from this session. |
void |
setCacheMode(CacheMode cacheMode)
Set the cache mode.
|
void |
setDefaultReadOnly(boolean 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.
|
void |
setFlushMode(FlushMode flushMode)
Deprecated.
(since 5.2) use
setHibernateFlushMode(FlushMode) instead |
void |
setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.
|
void |
setReadOnly(Object entityOrProxy,
boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only
object to modifiable mode.
|
void |
update(Object object)
Update the persistent instance with the identifier of the given detached
instance.
|
void |
update(String entityName,
Object object)
Update the persistent instance with the identifier of the given detached
instance.
|
beginTransaction, close, createCriteria, createCriteria, createCriteria, createCriteria, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, getJdbcBatchSize, getNamedProcedureCall, getTenantIdentifier, getTransaction, isConnected, isOpen, setJdbcBatchSize
getSession
close, contains, createEntityGraph, createEntityGraph, createNamedQuery, createNamedStoredProcedureQuery, createNativeQuery, createNativeQuery, createNativeQuery, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, detach, find, find, find, find, getCriteriaBuilder, getDelegate, getEntityGraph, getEntityGraphs, getEntityManagerFactory, getLockMode, getMetamodel, getProperties, getReference, getTransaction, isJoinedToTransaction, isOpen, joinTransaction, lock, lock, refresh, refresh, refresh, remove, setFlushMode, setProperty, unwrap
createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, getNamedNativeQuery, getNamedSQLQuery
SharedSessionBuilder sessionWithOptions()
Session
builder with the ability to grab certain information from this session.void flush() throws HibernateException
setFlushMode(FlushMode)
,
EntityTransaction.commit()
calls this method).
Flushing is the process of synchronizing the underlying persistent
store with persistable state held in memory.flush
in interface EntityManager
HibernateException
- Indicates problems flushing the session or
talking to the database.@Deprecated void setFlushMode(FlushMode flushMode)
setHibernateFlushMode(FlushMode)
insteadFlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).flushMode
- the new flush modeFlushModeType getFlushMode()
FlushModeType
rather than Hibernate's FlushMode
. For
the former behavior, use getHibernateFlushMode()
instead.getFlushMode
in interface EntityManager
void setHibernateFlushMode(FlushMode flushMode)
FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).flushMode
- the new flush modeFlushMode getHibernateFlushMode()
void setCacheMode(CacheMode cacheMode)
cacheMode
- The new cache mode.CacheMode getCacheMode()
SessionFactory getSessionFactory()
SessionFactory
void cancelQuery() throws HibernateException
HibernateException
- There was a problem canceling the queryboolean isDirty() throws HibernateException
HibernateException
- could not perform dirtying checkingboolean isDefaultReadOnly()
isReadOnly(Object)
void setDefaultReadOnly(boolean readOnly)
readOnly
- true, the default for loaded entities/proxies is read-only;
false, the default for loaded entities/proxies is modifiableTo override this session's read-only/modifiable setting for entities
and proxies loaded by a Query:
,
Query.setReadOnly(boolean)
Serializable getIdentifier(Object object)
object
- a persistent instanceTransientObjectException
- if the instance is transient or associated with
a different sessionboolean contains(String entityName, Object object)
entityName
- The entity nameobject
- an instance of a persistent classvoid evict(Object object)
object
- The entity to evictNullPointerException
- if the passed object is null
IllegalArgumentException
- if the passed object is not defined as an entity<T> T load(Class<T> theClass, Serializable id, LockMode lockMode)
load(Class, Serializable, LockOptions)
theClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock levelload(Class, Serializable, LockOptions)
<T> T load(Class<T> theClass, Serializable id, LockOptions lockOptions)
theClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockOptions
- contains the lock levelObject load(String entityName, Serializable id, LockMode lockMode)
load(String, Serializable, LockOptions)
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock levelload(String, Serializable, LockOptions)
Object load(String entityName, Serializable id, LockOptions lockOptions)
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockOptions
- contains the lock level<T> T load(Class<T> theClass, Serializable id)
theClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classObject load(String entityName, Serializable id)
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classvoid load(Object object, Serializable id)
object
- an "empty" instance of the persistent classid
- a valid identifier of an existing persistent instance of the classvoid replicate(Object object, ReplicationMode replicationMode)
cascade="replicate"
object
- a detached instance of a persistent classreplicationMode
- The replication mode to usevoid replicate(String entityName, Object object, ReplicationMode replicationMode)
cascade="replicate"
entityName
- The entity nameobject
- a detached instance of a persistent classreplicationMode
- The replication mode to useSerializable save(Object object)
cascade="save-update"
object
- a transient instance of a persistent classSerializable save(String entityName, Object object)
cascade="save-update"
entityName
- The entity nameobject
- a transient instance of a persistent classvoid saveOrUpdate(Object object)
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).
This operation cascades to associated instances if the association is mapped
with cascade="save-update"
object
- a transient or detached instance containing new or updated statesave(java.lang.Object)
,
update(Object object)
void saveOrUpdate(String entityName, Object object)
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).
This operation cascades to associated instances if the association is mapped
with cascade="save-update"
entityName
- The entity nameobject
- a transient or detached instance containing new or updated statesave(String,Object)
,
update(String,Object)
void update(Object object)
cascade="save-update"
object
- a detached instance containing updated statevoid update(String entityName, Object object)
cascade="save-update"
entityName
- The entity nameobject
- a detached instance containing updated stateObject merge(Object object)
cascade="merge"
The semantics of this method are defined by JSR-220.merge
in interface EntityManager
object
- a detached instance with state to be copiedObject merge(String entityName, Object object)
cascade="merge"
The semantics of this method are defined by JSR-220.entityName
- The entity nameobject
- a detached instance with state to be copiedvoid persist(Object object)
cascade="persist"
The semantics of this method are defined by JSR-220.persist
in interface EntityManager
object
- a transient instance to be made persistentvoid persist(String entityName, Object object)
cascade="persist"
The semantics of this method are defined by JSR-220.entityName
- The entity nameobject
- a transient instance to be made persistentvoid delete(Object object)
cascade="delete"
object
- the instance to be removedvoid delete(String entityName, Object object)
cascade="delete"
entityName
- The entity name for the instance to be removed.object
- the instance to be removedvoid lock(Object object, LockMode lockMode)
Session.LockRequest.lock(Object)
via buildLockRequest(LockOptions)
object
- a persistent or transient instancelockMode
- the lock levelbuildLockRequest(LockOptions)
,
Session.LockRequest.lock(Object)
void lock(String entityName, Object object, LockMode lockMode)
Session.LockRequest.lock(String, Object)
via buildLockRequest(LockOptions)
entityName
- The name of the entityobject
- a persistent or transient instancelockMode
- the lock levelbuildLockRequest(LockOptions)
,
Session.LockRequest.lock(String, Object)
Session.LockRequest buildLockRequest(LockOptions lockOptions)
session.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(60000).lock(entity);
lockOptions
- contains the lock levelvoid refresh(Object object)
refresh
in interface EntityManager
object
- a persistent or detached instancevoid refresh(String entityName, Object object)
entityName
- a persistent classobject
- a persistent or detached instancevoid refresh(Object object, LockMode lockMode)
refresh(Object, LockOptions)
object
- a persistent or detached instancelockMode
- the lock mode to userefresh(Object, LockOptions)
void refresh(Object object, LockOptions lockOptions)
object
- a persistent or detached instancelockOptions
- contains the lock mode to usevoid refresh(String entityName, Object object, LockOptions lockOptions)
entityName
- a persistent classobject
- a persistent or detached instancelockOptions
- contains the lock mode to useLockMode getCurrentLockMode(Object object)
object
- a persistent instance@Deprecated Query createFilter(Object collection, String queryString)
Query
instance for the given collection and filter string. Contains an implicit FROM
element named this
which refers to the defined table for the collection elements, as well as an implicit
WHERE
restriction for this particular collection instance's key value.collection
- a persistent collectionqueryString
- a Hibernate query fragment.void clear()
clear
in interface EntityManager
<T> T get(Class<T> entityType, Serializable id)
entityType
- The entity typeid
- an identifier<T> T get(Class<T> entityType, Serializable id, LockMode lockMode)
get(Class, Serializable, LockOptions)
entityType
- The entity typeid
- an identifierlockMode
- the lock modeget(Class, Serializable, LockOptions)
<T> T get(Class<T> entityType, Serializable id, LockOptions lockOptions)
entityType
- The entity typeid
- an identifierlockOptions
- the lock modeObject get(String entityName, Serializable id)
entityName
- the entity nameid
- an identifierObject get(String entityName, Serializable id, LockMode lockMode)
get(String, Serializable, LockOptions)
entityName
- the entity nameid
- an identifierlockMode
- the lock modeget(String, Serializable, LockOptions)
Object get(String entityName, Serializable id, LockOptions lockOptions)
entityName
- the entity nameid
- an identifierlockOptions
- contains the lock modeString getEntityName(Object object)
object
- a persistent entityIdentifierLoadAccess byId(String entityName)
IdentifierLoadAccess
instance to retrieve the specified entity type by
primary key.entityName
- The entity name of the entity type to be retrievedHibernateException
- If the specified entity name cannot be resolved as an entity name<T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
MultiIdentifierLoadAccess
instance to retrieve multiple entities at once
as specified by primary key values.entityClass
- The entity type to be retrievedHibernateException
- If the specified Class cannot be resolved as a mapped entityMultiIdentifierLoadAccess byMultipleIds(String entityName)
MultiIdentifierLoadAccess
instance to retrieve multiple entities at once
as specified by primary key values.entityName
- The entity name of the entity type to be retrievedHibernateException
- If the specified entity name cannot be resolved as an entity name<T> IdentifierLoadAccess<T> byId(Class<T> entityClass)
IdentifierLoadAccess
instance to retrieve the specified entity by
primary key.entityClass
- The entity type to be retrievedHibernateException
- If the specified Class cannot be resolved as a mapped entityNaturalIdLoadAccess byNaturalId(String entityName)
NaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.entityName
- The entity name of the entity type to be retrievedHibernateException
- If the specified entity name cannot be resolved as an entity name<T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
NaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.entityClass
- The entity type to be retrievedHibernateException
- If the specified Class cannot be resolved as a mapped entitySimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName)
SimpleNaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.entityName
- The entity name of the entity type to be retrievedHibernateException
- If the specified entityClass cannot be resolved as a mapped entity, or if the
entity does not define a natural-id or if its natural-id is made up of multiple attributes.<T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
SimpleNaturalIdLoadAccess
instance to retrieve the specified entity by
its simple (single attribute) natural id.entityClass
- The entity type to be retrievedHibernateException
- If the specified entityClass cannot be resolved as a mapped entity, or if the
entity does not define a natural-id or if its natural-id is made up of multiple attributes.Filter enableFilter(String filterName)
filterName
- The name of the filter to be enabled.Filter getEnabledFilter(String filterName)
filterName
- The name of the filter to be retrieved.void disableFilter(String filterName)
filterName
- The name of the filter to be disabled.SessionStatistics getStatistics()
boolean isReadOnly(Object entityOrProxy)
entityOrProxy
- an entity or HibernateProxytrue
if the entity or proxy is read-only, false
if the entity or proxy is modifiable.isDefaultReadOnly()
void setReadOnly(Object entityOrProxy, boolean readOnly)
entityOrProxy
- an entity or HibernateProxyreadOnly
- true
if the entity or proxy should be made read-only; false
if the entity or
proxy should be made modifiableTo override this session's read-only/modifiable setting for entities
and proxies loaded by a Query:
,
Query.setReadOnly(boolean)
void doWork(Work work) throws HibernateException
work
- The work to be performed.HibernateException
- Generally indicates wrapped SQLException
<T> T doReturningWork(ReturningWork<T> work) throws HibernateException
ReturningWork.execute(java.sql.Connection)
call.T
- The type of the result returned from the workwork
- The work to be performed.ReturningWork.execute(java.sql.Connection)
.HibernateException
- Generally indicates wrapped SQLException
Connection disconnect()
null
reconnect(Connection)
void reconnect(Connection connection)
connection
- a JDBC connectiondisconnect()
boolean isFetchProfileEnabled(String name) throws UnknownProfileException
name
- The name of the profile to be checked.UnknownProfileException
- Indicates that the given name does not
match any known profile namesfor discussion of this feature
void enableFetchProfile(String name) throws UnknownProfileException
name
- The name of the fetch profile to be enabled.UnknownProfileException
- Indicates that the given name does not
match any known profile namesfor discussion of this feature
void disableFetchProfile(String name) throws UnknownProfileException
name
- The name of the fetch profile to be disabled.UnknownProfileException
- Indicates that the given name does not
match any known profile namesfor discussion of this feature
TypeHelper getTypeHelper()
TypeHelper
associated with this session's SessionFactory
.
Equivalent to calling getSessionFactory()
.getTypeHelper()
TypeHelper
associated with this session's SessionFactory
LobHelper getLobHelper()
void addEventListeners(SessionEventListener... listeners)
listeners
- The listener(s) to addQuery createQuery(String queryString)
QueryProducer
Query
instance for the given HQL/JPQL query string.createQuery
in interface EntityManager
createQuery
in interface QueryProducer
queryString
- The HQL/JPQL queryEntityManager.createQuery(String)
<T> Query<T> createQuery(String queryString, Class<T> resultType)
QueryProducer
Query
instance for the given HQL/JPQL query string.createQuery
in interface EntityManager
createQuery
in interface QueryProducer
queryString
- The HQL/JPQL queryresultType
- the type of the query resultEntityManager.createQuery(String,Class)
<T> Query<T> createQuery(CriteriaQuery<T> criteriaQuery)
EntityManager
TypedQuery
for executing a
criteria query.createQuery
in interface EntityManager
criteriaQuery
- a criteria query objectQuery createQuery(CriteriaUpdate updateQuery)
EntityManager
Query
for executing a criteria
update query.createQuery
in interface EntityManager
updateQuery
- a criteria update query objectQuery createQuery(CriteriaDelete deleteQuery)
EntityManager
Query
for executing a criteria
delete query.createQuery
in interface EntityManager
deleteQuery
- a criteria delete query objectQuery getNamedQuery(String queryName)
QueryProducer
Query
instance for the named query.getNamedQuery
in interface QueryProducer
queryName
- the name of a pre-defined, named query<T> Query<T> createNamedQuery(String name, Class<T> resultType)
QueryProducer
createNamedQuery
in interface EntityManager
createNamedQuery
in interface QueryProducer
name
- the name of a query defined in metadataresultType
- the type of the query resultEntityManager.createNamedQuery(String,Class)
NativeQuery createSQLQuery(String queryString)
QueryProducer
NativeQuery
instance for the given SQL query string.createSQLQuery
in interface QueryProducer
queryString
- The SQL queryCopyright © 2019 JBoss by Red Hat. All rights reserved.