public final class SessionImpl extends AbstractSessionImpl implements EventSource, SessionImplementor, HibernateEntityManagerImplementor
Session
to the applicationSessionImplementor
to other Hibernate components (SPI)Modifier and Type | Class and Description |
---|---|
static class |
SessionImpl.ManagedFlushCheckerStandardImpl |
Session.LockRequest
LobCreationContext.Callback<T>
HibernateEntityManagerImplementor.QueryOptions
closed, exceptionConverter, waitingForAutoClose
Constructor and Description |
---|
SessionImpl(SessionFactoryImpl factory,
SessionCreationOptions options) |
Modifier and Type | Method and Description |
---|---|
void |
addEventListeners(SessionEventListener... listeners)
Add one or more listeners to the Session
|
protected void |
addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) |
void |
afterOperation(boolean success)
Check if there is a Hibernate or JTA transaction in progress and,
if there is not, flush if necessary, make sure the connection has
been committed (if it is not in autocommit mode) and run the after
completion processing
|
void |
afterScrollOperation() |
void |
afterTransactionBegin()
A after-begin callback from the coordinator to its owner.
|
void |
afterTransactionCompletion(boolean successful,
boolean delayed)
An after-completion callback to the owner.
|
protected void |
applyQuerySettingsAndHints(Query query) |
protected boolean |
autoFlushIfRequired(Set querySpaces)
detect in-memory changes, determine if the changes are to tables
named in the query and, if so, complete execution the flush
|
void |
beforeTransactionCompletion()
A before-completion callback to the owner.
|
String |
bestGuessEntityName(Object object)
The best guess entity name for an entity not in an association
|
Session.LockRequest |
buildLockRequest(LockOptions lockOptions)
Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.
|
<T> org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl<T> |
byId(Class<T> entityClass)
Create an
IdentifierLoadAccess instance to retrieve the specified entity by
primary key. |
org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl |
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.
|
protected void |
checkSessionFactoryOpen() |
protected void |
cleanupOnClose()
clear all the internal collections, just
to help the garbage collector, does not
clear anything that is needed during the
afterTransactionCompletion() phase
|
void |
clear()
Completely clear the session.
|
void |
close()
End the session by releasing the JDBC connection and cleaning up.
|
void |
closeWithoutOpenChecks() |
Connection |
connection() |
boolean |
contains(Object object)
Check if the instance is a managed entity instance belonging
to the current persistence context.
|
boolean |
contains(String entityName,
Object object)
Check if this entity is associated with this Session.
|
Criteria |
createCriteria(Class persistentClass)
Create
Criteria instance for the given class (entity or subclasses/implementors). |
Criteria |
createCriteria(Class persistentClass,
String alias)
Create
Criteria instance for the given class (entity or subclasses/implementors), using a specific
alias. |
Criteria |
createCriteria(String entityName)
Create
Criteria instance for the given entity name. |
Criteria |
createCriteria(String entityName,
String alias)
Create
Criteria instance for the given entity name, using a specific alias. |
<T> EntityGraph<T> |
createEntityGraph(Class<T> rootType)
Return a mutable EntityGraph that can be used to dynamically create an
EntityGraph.
|
EntityGraph<?> |
createEntityGraph(String graphName)
Return a mutable copy of the named EntityGraph.
|
Query |
createFilter(Object collection,
String queryString)
Create a
Query instance for the given collection and filter string. |
StoredProcedureQuery |
createNamedStoredProcedureQuery(String name)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
QueryImplementor |
createQuery(CriteriaDelete criteriaDelete)
Create an instance of
Query for executing a criteria
delete query. |
<T> QueryImplementor<T> |
createQuery(CriteriaQuery<T> criteriaQuery)
Create an instance of
TypedQuery for executing a
criteria query. |
QueryImplementor |
createQuery(CriteriaUpdate criteriaUpdate)
Create an instance of
Query for executing a criteria
update query. |
<T> QueryImplementor<T> |
createQuery(String jpaqlString,
Class<T> resultClass,
Selection selection,
HibernateEntityManagerImplementor.QueryOptions queryOptions)
Used during "compiling" a JPA criteria query.
|
ProcedureCall |
createStoredProcedureCall(String procedureName)
Creates a call to a stored procedure.
|
ProcedureCall |
createStoredProcedureCall(String procedureName,
Class... resultClasses)
Creates a call to a stored procedure with specific result set entity mappings.
|
ProcedureCall |
createStoredProcedureCall(String procedureName,
String... resultSetMappings)
Creates a call to a stored procedure with specific result set entity mappings.
|
StoredProcedureQuery |
createStoredProcedureQuery(String procedureName)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
StoredProcedureQuery |
createStoredProcedureQuery(String procedureName,
Class... resultClasses)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
StoredProcedureQuery |
createStoredProcedureQuery(String procedureName,
String... resultSetMappings)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
protected CriteriaCompiler |
criteriaCompiler() |
protected void |
delayedAfterCompletion() |
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 |
delete(String entityName,
Object object,
boolean isCascadeDeleteEnabled,
Set transientEntities)
Cascade delete an entity instance
|
void |
detach(Object entity)
Remove the given entity from the persistence context, causing
a managed entity to become detached.
|
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 any hard references to the entity that are held by the infrastructure
(references held by application or other persistent instances are okay)
|
int |
executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification,
QueryParameters queryParameters)
Execute a native SQL update or delete query
|
int |
executeUpdate(String query,
QueryParameters queryParameters)
Execute a HQL update or delete query
|
<T> T |
find(Class<T> entityClass,
Object primaryKey)
Find by primary key.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
LockModeType lockModeType)
Find by primary key and lock.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
LockModeType lockModeType,
Map<String,Object> properties)
Find by primary key and lock, using the specified properties.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
Map<String,Object> properties)
Find by primary key, using the specified properties.
|
void |
flush()
Force this session to flush.
|
void |
flushBeforeTransactionCompletion() |
void |
forceFlush(EntityEntry entityEntry)
Force an immediate flush
|
<T> T |
get(Class<T> entityClass,
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> entityClass,
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> entityClass,
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.
|
ActionQueue |
getActionQueue()
Get the ActionQueue for this session
|
Serializable |
getContextEntityIdentifier(Object object)
Get the id value for an object that is actually associated with the session.
|
CriteriaBuilder |
getCriteriaBuilder()
Return an instance of
CriteriaBuilder for the creation of
CriteriaQuery objects. |
LockMode |
getCurrentLockMode(Object object)
Determine the current lock mode of the given object.
|
Object |
getDelegate()
Return the underlying provider object for the
EntityManager ,
if available. |
int |
getDontFlushFromFind() |
Filter |
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.
|
EntityGraph<?> |
getEntityGraph(String graphName)
Return a named EntityGraph.
|
<T> List<EntityGraph<? super T>> |
getEntityGraphs(Class<T> entityClass)
Return all named EntityGraphs that have been defined for the provided
class type.
|
SessionFactoryImplementor |
getEntityManagerFactory()
Return the entity manager factory for the entity manager.
|
String |
getEntityName(Object object)
Return the entity name for a persistent entity.
|
EntityPersister |
getEntityPersister(String entityName,
Object object)
Get the EntityPersister for any instance
|
Object |
getEntityUsingInterceptor(EntityKey key)
Get the entity instance associated with the given Key,
calling the Interceptor if necessary
|
Serializable |
getIdentifier(Object object)
Return the identifier value of the given entity as associated with this
session.
|
LoadQueryInfluencers |
getLoadQueryInfluencers()
Get the load query influencers associated with this session.
|
LobHelper |
getLobHelper()
Retrieve this session's helper/delegate for creating LOB instances.
|
LockModeType |
getLockMode(Object entity)
Get the current lock mode for the entity instance.
|
LockOptions |
getLockRequest(LockModeType lockModeType,
Map<String,Object> properties)
Convert from JPA 2
LockModeType & properties into LockOptions |
MetamodelImplementor |
getMetamodel()
Return an instance of
Metamodel interface for access to the
metamodel of the persistence unit. |
PersistenceContext |
getPersistenceContext()
Get the persistence context for this session
|
Map<String,Object> |
getProperties()
Get the properties and hints and associated values that are in effect
for the entity manager.
|
<T> T |
getReference(Class<T> entityClass,
Object primaryKey)
Get an instance, whose state may be lazily fetched.
|
SessionImplementor |
getSession()
Retrieve a reference to the Hibernate
Session used by this EntityManager . |
SessionFactoryImplementor |
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 . |
String |
guessEntityName(Object object)
The guessed entity name for an entity not in an association
|
Object |
immediateLoad(String entityName,
Serializable id)
Load the data for the object with the specified id into a newly created object.
|
void |
initializeCollection(PersistentCollection collection,
boolean writing)
Initialize the collection (if not already initialized)
|
protected void |
initQueryFromNamedDefinition(Query query,
NamedQueryDefinition namedQueryDefinition) |
Object |
instantiate(EntityPersister persister,
Serializable id)
give the interceptor an opportunity to override the default instantiation
|
Object |
instantiate(String entityName,
Serializable id)
Instantiate the entity class, initializing with the given identifier
|
Object |
internalLoad(String entityName,
Serializable id,
boolean eager,
boolean nullable)
Load an instance without checking if it was deleted.
|
boolean |
isAutoCloseSessionEnabled() |
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 |
isEventSource() |
boolean |
isFetchProfileEnabled(String name)
Is a particular fetch profile enabled on this session?
|
boolean |
isFlushBeforeCompletionEnabled() |
boolean |
isJoinedToTransaction()
Determine whether the entity manager is joined to the
current transaction.
|
boolean |
isOpen()
Check if the session is still open.
|
boolean |
isQueryParametersValidationEnabled() |
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:
|
Iterator |
iterate(String query,
QueryParameters queryParameters)
Execute an iterate() query
|
Iterator |
iterateFilter(Object collection,
String filter,
QueryParameters queryParameters)
Iterate a filter
|
void |
joinTransaction()
Indicate to the entity manager that a JTA transaction is
active and join the persistence context to it.
|
List |
list(Criteria criteria)
Execute a criteria query
|
List |
list(String query,
QueryParameters queryParameters)
Execute a find() query
|
List |
listCustomQuery(CustomQuery customQuery,
QueryParameters queryParameters)
Execute an SQL Query
|
List |
listFilter(Object collection,
String filter,
QueryParameters queryParameters)
Execute a filter
|
<T> T |
load(Class<T> entityClass,
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> entityClass,
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> entityClass,
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(Object entity,
LockModeType lockModeType)
Lock an entity instance that is contained in the persistence
context with the specified lock mode type.
|
void |
lock(Object entity,
LockModeType lockModeType,
Map<String,Object> properties)
Lock an entity instance that is contained in the persistence
context with the specified lock mode type and with specified
properties.
|
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 |
merge(String entityName,
Object object,
Map copiedAlready)
Cascade merge an entity instance
|
void |
persist(Object object)
Make a transient instance persistent.
|
void |
persist(String entityName,
Object object)
Make a transient instance persistent.
|
void |
persist(String entityName,
Object object,
Map copiedAlready)
Cascade persist an entity instance
|
void |
persistOnFlush(Object object) |
void |
persistOnFlush(String entityName,
Object object) |
void |
persistOnFlush(String entityName,
Object object,
Map copiedAlready)
Cascade persist an entity instance during the flush process
|
void |
reconnect(Connection conn)
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 entity,
LockModeType lockModeType)
Refresh the state of the instance from the database,
overwriting changes made to the entity, if any, and
lock it with respect to given lock mode type.
|
void |
refresh(Object entity,
LockModeType lockModeType,
Map<String,Object> properties)
Refresh the state of the instance from the database,
overwriting changes made to the entity, if any, and
lock it with respect to given lock mode type and with
specified properties.
|
void |
refresh(Object object,
LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with
the given LockMode.
|
void |
refresh(Object entity,
Map<String,Object> properties)
Refresh the state of the instance from the database, using
the specified properties, and overwriting changes made to
the entity, if any.
|
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 |
refresh(String entityName,
Object object,
Map refreshedAlready)
Cascade refresh an entity instance
|
void |
remove(Object entity)
Remove the entity instance.
|
void |
removeOrphanBeforeUpdates(String entityName,
Object child)
A specialized type of deletion for orphan removal that must occur prior to queued inserts and updates.
|
protected void |
removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) |
void |
replicate(Object obj,
ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current
identifier value.
|
void |
replicate(String entityName,
Object obj,
ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current
identifier value.
|
Serializable |
save(Object obj)
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
Session.save(Object) or Session.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 obj)
Either
Session.save(String, Object) or Session.update(String, Object)
the given instance, depending upon resolution of the unsaved-value checks
(see the manual for discussion of unsaved-value checking). |
ScrollableResultsImplementor |
scroll(Criteria criteria,
ScrollMode scrollMode)
Execute a criteria query
|
ScrollableResultsImplementor |
scroll(String query,
QueryParameters queryParameters)
Execute a scroll() query
|
ScrollableResultsImplementor |
scrollCustomQuery(CustomQuery customQuery,
QueryParameters queryParameters)
Execute an SQL Query
|
SharedSessionBuilder |
sessionWithOptions()
Obtain a
Session builder with the ability to grab certain information from this session. |
void |
setAutoClear(boolean enabled)
Enable/disable automatic cache clearing from after transaction
completion (for EJB3)
|
void |
setDefaultReadOnly(boolean defaultReadOnly)
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(FlushModeType flushModeType)
Set the flush mode that applies to all objects contained
in the persistence context.
|
void |
setProperty(String propertyName,
Object value)
Set an entity manager property or hint.
|
void |
setReadOnly(Object entity,
boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only
object to modifiable mode.
|
boolean |
shouldAutoClose() |
protected boolean |
shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) |
void |
startTransactionBoundary()
Callback indicating recognition of entering into a transactional
context whether that is explicitly via the Hibernate
Transaction API or via registration
of Hibernate's JTA Synchronization impl with a JTA Transaction |
String |
toString() |
<T> T |
unwrap(Class<T> clazz)
Return an object of the specified type to allow access to the
provider-specific API.
|
void |
update(Object obj)
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.
|
accessTransaction, beginTransaction, buildQueryFromName, checkOpen, checkOpenOrWaitingForAutoClose, checkTransactionSynchStatus, createNamedQuery, createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, createQuery, createQuery, createQuery, createSQLQuery, errorIfClosed, execute, generateEntityKey, getCacheMode, getCacheTransactionSynchronization, getCurrentTransaction, getEntityNameResolver, getEventListenerManager, getExceptionConverter, getFactory, getFlushMode, getHibernateFlushMode, getInterceptor, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcCoordinator, getJdbcServices, getJdbcSessionContext, getJdbcTimeZone, getLobCreator, getNamedNativeQuery, getNamedProcedureCall, getNamedQuery, getNamedSQLQuery, getNativeQueryImplementor, getNativeQueryPlan, getQueryPlan, getSessionIdentifier, getTenantIdentifier, getTransaction, getTransactionCoordinator, getTransactionStartTimestamp, isClosed, isConnected, isOpenOrWaitingForAutoClose, isTransactionInProgress, list, markForRollbackOnly, pulseTransactionCoordinator, remapSqlTypeDescriptor, resultClassChecking, resultClassChecking, scroll, setCacheMode, setClosed, setFlushMode, setHibernateFlushMode, setJdbcBatchSize, shouldAutoJoinTransaction, useStreamForLobBinding
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createNamedQuery, createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, createQuery, createSQLQuery, getNamedNativeQuery, getNamedQuery, getNamedSQLQuery
getCacheMode, getFlushMode, getHibernateFlushMode, setCacheMode, setFlushMode, setHibernateFlushMode
accessTransaction, checkOpen, checkOpen, generateEntityKey, getCacheMode, getCacheTransactionSynchronization, getConfiguredJdbcBatchSize, getEventListenerManager, getExceptionConverter, getFactory, getFlushMode, getHibernateFlushMode, getInterceptor, getJdbcCoordinator, getJdbcServices, getSessionIdentifier, getTenantIdentifier, getTimestamp, getTransactionStartTimestamp, isClosed, isOpenOrWaitingForAutoClose, isTransactionInProgress, list, markForRollbackOnly, scroll, setCacheMode, setFlushMode, setHibernateFlushMode
beginTransaction, getJdbcBatchSize, getNamedProcedureCall, getTransaction, isConnected, setJdbcBatchSize
getJdbcBatchSize, getJdbcConnectionAccess, getJdbcSessionContext, getTransactionCoordinator
shouldAutoJoinTransaction
execute
getJdbcTimeZone, getLobCreator, remapSqlTypeDescriptor, useStreamForLobBinding
buildLockOptions, checkOpen, isTransactionInProgress, markForRollbackOnly
getTransaction
getFactory
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options)
protected void applyQuerySettingsAndHints(Query query)
applyQuerySettingsAndHints
in class AbstractSharedSessionContract
public SharedSessionBuilder sessionWithOptions()
Session
Session
builder with the ability to grab certain information from this session.sessionWithOptions
in interface Session
public void clear()
Session
clear
in interface EntityManager
clear
in interface Session
public void close() throws HibernateException
SharedSessionContract
close
in interface Closeable
close
in interface AutoCloseable
close
in interface EntityManager
close
in interface SharedSessionContract
close
in class AbstractSharedSessionContract
HibernateException
- Indicates problems cleaning up.public void closeWithoutOpenChecks() throws HibernateException
HibernateException
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
shouldCloseJdbcCoordinatorOnClose
in class AbstractSharedSessionContract
public boolean isAutoCloseSessionEnabled()
isAutoCloseSessionEnabled
in interface SharedSessionContractImplementor
public boolean isQueryParametersValidationEnabled()
isQueryParametersValidationEnabled
in interface SharedSessionContractImplementor
public boolean isOpen()
SharedSessionContract
isOpen
in interface EntityManager
isOpen
in interface SharedSessionContract
isOpen
in class AbstractSharedSessionContract
protected void checkSessionFactoryOpen()
public boolean shouldAutoClose()
shouldAutoClose
in interface SharedSessionContractImplementor
public Connection connection() throws HibernateException
connection
in interface SharedSessionContractImplementor
HibernateException
public Connection disconnect() throws HibernateException
Session
disconnect
in interface Session
null
HibernateException
Session.reconnect(Connection)
public void reconnect(Connection conn) throws HibernateException
Session
reconnect
in interface Session
conn
- a JDBC connectionHibernateException
Session.disconnect()
public void setAutoClear(boolean enabled)
SharedSessionContractImplementor
setAutoClear
in interface SharedSessionContractImplementor
public void afterOperation(boolean success)
success
- Was the operation a successpublic void addEventListeners(SessionEventListener... listeners)
Session
addEventListeners
in interface Session
listeners
- The listener(s) to addprotected void cleanupOnClose()
cleanupOnClose
in class AbstractSharedSessionContract
public LockMode getCurrentLockMode(Object object) throws HibernateException
Session
getCurrentLockMode
in interface Session
object
- a persistent instanceHibernateException
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
SharedSessionContractImplementor
getEntityUsingInterceptor
in interface SharedSessionContractImplementor
HibernateException
protected void delayedAfterCompletion()
delayedAfterCompletion
in class AbstractSharedSessionContract
public void saveOrUpdate(Object object) throws HibernateException
Session
Session.save(Object)
or Session.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"
saveOrUpdate
in interface Session
object
- a transient or detached instance containing new or updated stateHibernateException
Session.save(java.lang.Object)
,
Session.update(Object object)
public void saveOrUpdate(String entityName, Object obj) throws HibernateException
Session
Session.save(String, Object)
or Session.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"
saveOrUpdate
in interface Session
entityName
- The entity nameobj
- a transient or detached instance containing new or updated stateHibernateException
Session.save(String,Object)
,
Session.update(String,Object)
public Serializable save(Object obj) throws HibernateException
Session
cascade="save-update"
save
in interface Session
obj
- a transient instance of a persistent classHibernateException
public Serializable save(String entityName, Object object) throws HibernateException
Session
cascade="save-update"
save
in interface Session
entityName
- The entity nameobject
- a transient instance of a persistent classHibernateException
public void update(Object obj) throws HibernateException
Session
cascade="save-update"
update
in interface Session
obj
- a detached instance containing updated stateHibernateException
public void update(String entityName, Object object) throws HibernateException
Session
cascade="save-update"
update
in interface Session
entityName
- The entity nameobject
- a detached instance containing updated stateHibernateException
public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException
Session
Session.LockRequest.lock(String, Object)
via Session.buildLockRequest(LockOptions)
lock
in interface Session
entityName
- The name of the entityobject
- a persistent or transient instancelockMode
- the lock levelHibernateException
Session.buildLockRequest(LockOptions)
,
Session.LockRequest.lock(String, Object)
public Session.LockRequest buildLockRequest(LockOptions lockOptions)
Session
session.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(60000).lock(entity);
buildLockRequest
in interface Session
lockOptions
- contains the lock levelpublic void lock(Object object, LockMode lockMode) throws HibernateException
Session
Session.LockRequest.lock(Object)
via Session.buildLockRequest(LockOptions)
lock
in interface Session
object
- a persistent or transient instancelockMode
- the lock levelHibernateException
Session.buildLockRequest(LockOptions)
,
Session.LockRequest.lock(Object)
public void persist(String entityName, Object object) throws HibernateException
Session
cascade="persist"
The semantics of this method are defined by JSR-220.persist
in interface Session
entityName
- The entity nameobject
- a transient instance to be made persistentHibernateException
public void persist(Object object) throws HibernateException
Session
cascade="persist"
The semantics of this method are defined by JSR-220.persist
in interface EntityManager
persist
in interface Session
object
- a transient instance to be made persistentHibernateException
public void persist(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSource
persist
in interface SessionImplementor
persist
in interface EventSource
HibernateException
public void persistOnFlush(String entityName, Object object) throws HibernateException
HibernateException
public void persistOnFlush(Object object) throws HibernateException
HibernateException
public void persistOnFlush(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSource
persistOnFlush
in interface SessionImplementor
persistOnFlush
in interface EventSource
HibernateException
public Object merge(String entityName, Object object) throws HibernateException
Session
cascade="merge"
The semantics of this method are defined by JSR-220.merge
in interface Session
entityName
- The entity nameobject
- a detached instance with state to be copiedHibernateException
public Object merge(Object object) throws HibernateException
Session
cascade="merge"
The semantics of this method are defined by JSR-220.merge
in interface EntityManager
merge
in interface Session
object
- a detached instance with state to be copiedHibernateException
public void merge(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSource
merge
in interface SessionImplementor
merge
in interface EventSource
HibernateException
public void delete(Object object) throws HibernateException
Session
cascade="delete"
delete
in interface Session
object
- the instance to be removedHibernateException
public void delete(String entityName, Object object) throws HibernateException
Session
cascade="delete"
delete
in interface Session
entityName
- The entity name for the instance to be removed.object
- the instance to be removedHibernateException
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities) throws HibernateException
EventSource
delete
in interface SessionImplementor
delete
in interface EventSource
HibernateException
public void removeOrphanBeforeUpdates(String entityName, Object child)
EventSource
removeOrphanBeforeUpdates
in interface SessionImplementor
removeOrphanBeforeUpdates
in interface EventSource
public void load(Object object, Serializable id) throws HibernateException
Session
load
in interface Session
object
- an "empty" instance of the persistent classid
- a valid identifier of an existing persistent instance of the classHibernateException
public <T> T load(Class<T> entityClass, Serializable id) throws HibernateException
Session
load
in interface Session
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classHibernateException
public Object load(String entityName, Serializable id) throws HibernateException
Session
load
in interface Session
load
in class AbstractSharedSessionContract
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classHibernateException
public <T> T get(Class<T> entityClass, Serializable id) throws HibernateException
Session
get
in interface Session
entityClass
- The entity typeid
- an identifierHibernateException
public Object get(String entityName, Serializable id) throws HibernateException
Session
get
in interface Session
entityName
- the entity nameid
- an identifierHibernateException
public Object immediateLoad(String entityName, Serializable id) throws HibernateException
immediateLoad
in interface SharedSessionContractImplementor
HibernateException
public final Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException
SharedSessionContractImplementor
internalLoad
in interface SharedSessionContractImplementor
HibernateException
public <T> T load(Class<T> entityClass, Serializable id, LockMode lockMode) throws HibernateException
Session
Session.load(Class, Serializable, LockOptions)
load
in interface Session
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock levelHibernateException
Session.load(Class, Serializable, LockOptions)
public <T> T load(Class<T> entityClass, Serializable id, LockOptions lockOptions) throws HibernateException
Session
load
in interface Session
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockOptions
- contains the lock levelHibernateException
public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException
Session
Session.load(String, Serializable, LockOptions)
load
in interface Session
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock levelHibernateException
Session.load(String, Serializable, LockOptions)
public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException
Session
load
in interface Session
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockOptions
- contains the lock levelHibernateException
public <T> T get(Class<T> entityClass, Serializable id, LockMode lockMode) throws HibernateException
Session
Session.get(Class, Serializable, LockOptions)
get
in interface Session
entityClass
- The entity typeid
- an identifierlockMode
- the lock modeHibernateException
Session.get(Class, Serializable, LockOptions)
public <T> T get(Class<T> entityClass, Serializable id, LockOptions lockOptions) throws HibernateException
Session
get
in interface Session
entityClass
- The entity typeid
- an identifierlockOptions
- the lock modeHibernateException
public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException
Session
Session.get(String, Serializable, LockOptions)
get
in interface Session
entityName
- the entity nameid
- an identifierlockMode
- the lock modeHibernateException
Session.get(String, Serializable, LockOptions)
public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException
Session
get
in interface Session
entityName
- the entity nameid
- an identifierlockOptions
- contains the lock modeHibernateException
public org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl byId(String entityName)
Session
IdentifierLoadAccess
instance to retrieve the specified entity type by
primary key.public <T> org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl<T> byId(Class<T> entityClass)
Session
IdentifierLoadAccess
instance to retrieve the specified entity by
primary key.public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
Session
MultiIdentifierLoadAccess
instance to retrieve multiple entities at once
as specified by primary key values.byMultipleIds
in interface Session
entityClass
- The entity type to be retrievedpublic MultiIdentifierLoadAccess byMultipleIds(String entityName)
Session
MultiIdentifierLoadAccess
instance to retrieve multiple entities at once
as specified by primary key values.byMultipleIds
in interface Session
entityName
- The entity name of the entity type to be retrievedpublic NaturalIdLoadAccess byNaturalId(String entityName)
Session
NaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.byNaturalId
in interface Session
entityName
- The entity name of the entity type to be retrievedpublic <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
Session
NaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.byNaturalId
in interface Session
entityClass
- The entity type to be retrievedpublic SimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName)
Session
SimpleNaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.bySimpleNaturalId
in interface Session
entityName
- The entity name of the entity type to be retrievedpublic <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
Session
SimpleNaturalIdLoadAccess
instance to retrieve the specified entity by
its simple (single attribute) natural id.bySimpleNaturalId
in interface Session
entityClass
- The entity type to be retrievedpublic void refresh(Object object) throws HibernateException
Session
refresh
in interface EntityManager
refresh
in interface Session
object
- a persistent or detached instanceHibernateException
public void refresh(String entityName, Object object) throws HibernateException
Session
refresh
in interface Session
entityName
- a persistent classobject
- a persistent or detached instanceHibernateException
public void refresh(Object object, LockMode lockMode) throws HibernateException
Session
Session.refresh(Object, LockOptions)
refresh
in interface Session
object
- a persistent or detached instancelockMode
- the lock mode to useHibernateException
Session.refresh(Object, LockOptions)
public void refresh(Object object, LockOptions lockOptions) throws HibernateException
Session
refresh
in interface Session
object
- a persistent or detached instancelockOptions
- contains the lock mode to useHibernateException
public void refresh(String entityName, Object object, LockOptions lockOptions) throws HibernateException
Session
refresh
in interface Session
entityName
- a persistent classobject
- a persistent or detached instancelockOptions
- contains the lock mode to useHibernateException
public void refresh(String entityName, Object object, Map refreshedAlready) throws HibernateException
EventSource
refresh
in interface SessionImplementor
refresh
in interface EventSource
HibernateException
public void replicate(Object obj, ReplicationMode replicationMode) throws HibernateException
Session
cascade="replicate"
replicate
in interface Session
obj
- a detached instance of a persistent classreplicationMode
- The replication mode to useHibernateException
public void replicate(String entityName, Object obj, ReplicationMode replicationMode) throws HibernateException
Session
cascade="replicate"
replicate
in interface Session
entityName
- The entity nameobj
- a detached instance of a persistent classreplicationMode
- The replication mode to useHibernateException
public void evict(Object object) throws HibernateException
evict
in interface Session
object
- The entity to evictHibernateException
protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException
HibernateException
public boolean isDirty() throws HibernateException
Session
isDirty
in interface Session
HibernateException
- could not perform dirtying checkingpublic void flush() throws HibernateException
Session
Session.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
flush
in interface SharedSessionContractImplementor
flush
in interface Session
HibernateException
- Indicates problems flushing the session or
talking to the database.public void setFlushMode(FlushModeType flushModeType)
EntityManager
setFlushMode
in interface EntityManager
flushModeType
- flush modepublic void forceFlush(EntityEntry entityEntry) throws HibernateException
EventSource
forceFlush
in interface SessionImplementor
forceFlush
in interface EventSource
HibernateException
public List list(String query, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
list
in interface SharedSessionContractImplementor
HibernateException
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
executeUpdate
in interface SharedSessionContractImplementor
HibernateException
public int executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
executeNativeUpdate
in interface SharedSessionContractImplementor
HibernateException
public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
iterate
in interface SharedSessionContractImplementor
HibernateException
public ScrollableResultsImplementor scroll(String query, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
scroll
in interface SharedSessionContractImplementor
HibernateException
public Query createFilter(Object collection, String queryString)
Session
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.createFilter
in interface Session
collection
- a persistent collectionqueryString
- a Hibernate query fragment.public Object instantiate(String entityName, Serializable id) throws HibernateException
SharedSessionContractImplementor
instantiate
in interface SharedSessionContractImplementor
HibernateException
public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException
instantiate
in interface SessionImplementor
instantiate
in interface EventSource
HibernateException
public EntityPersister getEntityPersister(String entityName, Object object)
SharedSessionContractImplementor
getEntityPersister
in interface SharedSessionContractImplementor
entityName
- optional entity nameobject
- the entity instancepublic Serializable getIdentifier(Object object) throws HibernateException
Session
getIdentifier
in interface Session
object
- a persistent instanceTransientObjectException
- if the instance is transient or associated with
a different sessionHibernateException
public Serializable getContextEntityIdentifier(Object object)
getContextEntityIdentifier
in interface SharedSessionContractImplementor
public List listFilter(Object collection, String filter, QueryParameters queryParameters)
SharedSessionContractImplementor
listFilter
in interface SharedSessionContractImplementor
public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters)
SharedSessionContractImplementor
iterateFilter
in interface SharedSessionContractImplementor
public Criteria createCriteria(Class persistentClass, String alias)
SharedSessionContract
Criteria
instance for the given class (entity or subclasses/implementors), using a specific
alias.createCriteria
in interface SharedSessionContract
persistentClass
- The class, which is an entity, or has entity subclasses/implementorsalias
- The alias to usepublic Criteria createCriteria(String entityName, String alias)
SharedSessionContract
Criteria
instance for the given entity name, using a specific alias.createCriteria
in interface SharedSessionContract
entityName
- The entity namealias
- The alias to usepublic Criteria createCriteria(Class persistentClass)
SharedSessionContract
Criteria
instance for the given class (entity or subclasses/implementors).createCriteria
in interface SharedSessionContract
persistentClass
- The class, which is an entity, or has entity subclasses/implementorspublic Criteria createCriteria(String entityName)
SharedSessionContract
Criteria
instance for the given entity name.createCriteria
in interface SharedSessionContract
entityName
- The entity namepublic ScrollableResultsImplementor scroll(Criteria criteria, ScrollMode scrollMode)
SharedSessionContractImplementor
scroll
in interface SharedSessionContractImplementor
public List list(Criteria criteria) throws HibernateException
SharedSessionContractImplementor
list
in interface SharedSessionContractImplementor
HibernateException
public boolean contains(Object object)
EntityManager
contains
in interface EntityManager
object
- entity instancepublic boolean contains(String entityName, Object object)
Session
public ProcedureCall createStoredProcedureCall(String procedureName)
SharedSessionContract
createStoredProcedureCall
in interface SharedSessionContract
createStoredProcedureCall
in class AbstractSharedSessionContract
procedureName
- The name of the procedure.public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
SharedSessionContract
createStoredProcedureCall
in interface SharedSessionContract
createStoredProcedureCall
in class AbstractSharedSessionContract
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the resultspublic ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses)
SharedSessionContract
createStoredProcedureCall
in interface SharedSessionContract
createStoredProcedureCall
in class AbstractSharedSessionContract
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.public ScrollableResultsImplementor scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
SharedSessionContractImplementor
scrollCustomQuery
in interface SharedSessionContractImplementor
public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
SharedSessionContractImplementor
listCustomQuery
in interface SharedSessionContractImplementor
public SessionFactoryImplementor getSessionFactory()
Session
getSessionFactory
in interface SessionImplementor
getSessionFactory
in interface Session
SessionFactory
public void initializeCollection(PersistentCollection collection, boolean writing)
SharedSessionContractImplementor
initializeCollection
in interface SharedSessionContractImplementor
public String bestGuessEntityName(Object object)
SharedSessionContractImplementor
bestGuessEntityName
in interface SharedSessionContractImplementor
public String getEntityName(Object object)
Session
getEntityName
in interface Session
object
- a persistent entitypublic String guessEntityName(Object object) throws HibernateException
SharedSessionContractImplementor
guessEntityName
in interface SharedSessionContractImplementor
HibernateException
public void cancelQuery() throws HibernateException
Session
cancelQuery
in interface Session
HibernateException
- There was a problem canceling the querypublic int getDontFlushFromFind()
getDontFlushFromFind
in interface SharedSessionContractImplementor
public ActionQueue getActionQueue()
EventSource
getActionQueue
in interface SessionImplementor
getActionQueue
in interface EventSource
public PersistenceContext getPersistenceContext()
SharedSessionContractImplementor
getPersistenceContext
in interface SharedSessionContractImplementor
public SessionStatistics getStatistics()
Session
getStatistics
in interface Session
public boolean isEventSource()
isEventSource
in interface SharedSessionContractImplementor
public boolean isDefaultReadOnly()
Session
isDefaultReadOnly
in interface Session
Session.isReadOnly(Object)
public void setDefaultReadOnly(boolean defaultReadOnly)
Session
setDefaultReadOnly
in interface Session
defaultReadOnly
- 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)
public boolean isReadOnly(Object entityOrProxy)
Session
isReadOnly
in interface Session
entityOrProxy
- an entity or HibernateProxytrue
if the entity or proxy is read-only, false
if the entity or proxy is modifiable.Session.isDefaultReadOnly()
public void setReadOnly(Object entity, boolean readOnly)
Session
setReadOnly
in interface Session
entity
- 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)
public void doWork(Work work) throws HibernateException
Session
doWork
in interface Session
work
- The work to be performed.HibernateException
- Generally indicates wrapped SQLException
public <T> T doReturningWork(ReturningWork<T> work) throws HibernateException
Session
ReturningWork.execute(java.sql.Connection)
call.doReturningWork
in interface Session
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
public void afterScrollOperation()
afterScrollOperation
in interface SharedSessionContractImplementor
public LoadQueryInfluencers getLoadQueryInfluencers()
SharedSessionContractImplementor
getLoadQueryInfluencers
in interface SharedSessionContractImplementor
public Filter getEnabledFilter(String filterName)
Session
getEnabledFilter
in interface Session
filterName
- The name of the filter to be retrieved.public Filter enableFilter(String filterName)
Session
enableFilter
in interface Session
filterName
- The name of the filter to be enabled.public void disableFilter(String filterName)
Session
disableFilter
in interface Session
filterName
- The name of the filter to be disabled.public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
Session
isFetchProfileEnabled
in interface Session
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
public void enableFetchProfile(String name) throws UnknownProfileException
Session
enableFetchProfile
in interface Session
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
public void disableFetchProfile(String name) throws UnknownProfileException
Session
disableFetchProfile
in interface Session
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
public TypeHelper getTypeHelper()
Session
TypeHelper
associated with this session's SessionFactory
.
Equivalent to calling Session.getSessionFactory()
.getTypeHelper()
getTypeHelper
in interface Session
TypeHelper
associated with this session's SessionFactory
public LobHelper getLobHelper()
Session
getLobHelper
in interface Session
public void beforeTransactionCompletion()
JdbcSessionOwner
beforeTransactionCompletion
in interface JdbcSessionOwner
beforeTransactionCompletion
in class AbstractSharedSessionContract
public void afterTransactionCompletion(boolean successful, boolean delayed)
JdbcSessionOwner
afterTransactionCompletion
in interface JdbcSessionOwner
afterTransactionCompletion
in class AbstractSharedSessionContract
successful
- Was the transaction successful?delayed
- Is this a delayed after transaction completion call (aka after a timeout)?protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
addSharedSessionTransactionObserver
in class AbstractSharedSessionContract
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
removeSharedSessionTransactionObserver
in class AbstractSharedSessionContract
public void startTransactionBoundary()
JdbcSessionOwner
Transaction
API or via registration
of Hibernate's JTA Synchronization impl with a JTA TransactionstartTransactionBoundary
in interface JdbcSessionOwner
startTransactionBoundary
in class AbstractSharedSessionContract
public void afterTransactionBegin()
JdbcSessionOwner
afterTransactionBegin
in interface JdbcSessionOwner
public void flushBeforeTransactionCompletion()
flushBeforeTransactionCompletion
in interface JdbcSessionOwner
public boolean isFlushBeforeCompletionEnabled()
isFlushBeforeCompletionEnabled
in interface SessionImplementor
public SessionImplementor getSession()
HibernateEntityManager
Session
used by this EntityManager
.getSession
in interface HibernateEntityManager
getSession
in interface HibernateEntityManagerImplementor
public LockOptions getLockRequest(LockModeType lockModeType, Map<String,Object> properties)
HibernateEntityManagerImplementor
LockModeType
& properties into LockOptions
getLockRequest
in interface HibernateEntityManagerImplementor
lockModeType
- is the requested lock typeproperties
- are the lock propertiespublic <T> QueryImplementor<T> createQuery(String jpaqlString, Class<T> resultClass, Selection selection, HibernateEntityManagerImplementor.QueryOptions queryOptions)
SessionImplementor
createQuery
in interface SessionImplementor
createQuery
in interface HibernateEntityManagerImplementor
T
- The query typejpaqlString
- The criteria query rendered as a JPA QL stringresultClass
- The result type (the type expected in the result list)selection
- The selection(s)queryOptions
- The options to use to build the query.public void remove(Object entity)
EntityManager
remove
in interface EntityManager
entity
- entity instancepublic <T> T find(Class<T> entityClass, Object primaryKey)
EntityManager
find
in interface EntityManager
entityClass
- entity classprimaryKey
- primary keypublic <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
EntityManager
find
in interface EntityManager
entityClass
- entity classprimaryKey
- primary keyproperties
- standard and vendor-specific properties
and hintspublic <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType)
EntityManager
If the entity is found within the persistence context and the
lock mode type is pessimistic and the entity has a version
attribute, the persistence provider must perform optimistic
version checks when obtaining the database lock. If these
checks fail, the OptimisticLockException
will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException
will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException
will be thrown if the database
locking failure causes only statement-level rollback
find
in interface EntityManager
entityClass
- entity classprimaryKey
- primary keylockModeType
- lock modepublic <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String,Object> properties)
EntityManager
If the entity is found
within the persistence context and the lock mode type
is pessimistic and the entity has a version attribute, the
persistence provider must perform optimistic version checks
when obtaining the database lock. If these checks fail,
the OptimisticLockException
will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException
will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException
will be thrown if the database
locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
find
in interface EntityManager
entityClass
- entity classprimaryKey
- primary keylockModeType
- lock modeproperties
- standard and vendor-specific properties
and hintspublic <T> T getReference(Class<T> entityClass, Object primaryKey)
EntityManager
EntityNotFoundException
is thrown when the instance
state is first accessed. (The persistence provider runtime is
permitted to throw the EntityNotFoundException
when
getReference
is called.)
The application should not expect that the instance state will
be available upon detachment, unless it was accessed by the
application while the entity manager was open.getReference
in interface EntityManager
entityClass
- entity classprimaryKey
- primary keypublic void lock(Object entity, LockModeType lockModeType)
EntityManager
If a pessimistic lock mode type is specified and the entity
contains a version attribute, the persistence provider must
also perform optimistic version checks when obtaining the
database lock. If these checks fail, the
OptimisticLockException
will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException
will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException
will be thrown if the database
locking failure causes only statement-level rollback
lock
in interface EntityManager
entity
- entity instancelockModeType
- lock modepublic void lock(Object entity, LockModeType lockModeType, Map<String,Object> properties)
EntityManager
If a pessimistic lock mode type is specified and the entity
contains a version attribute, the persistence provider must
also perform optimistic version checks when obtaining the
database lock. If these checks fail, the
OptimisticLockException
will be thrown.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException
will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException
will be thrown if the database
locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
lock
in interface EntityManager
entity
- entity instancelockModeType
- lock modeproperties
- standard and vendor-specific properties
and hintspublic void refresh(Object entity, Map<String,Object> properties)
EntityManager
If a vendor-specific property or hint is not recognized, it is silently ignored.
refresh
in interface EntityManager
entity
- entity instanceproperties
- standard and vendor-specific properties
and hintspublic void refresh(Object entity, LockModeType lockModeType)
EntityManager
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException
will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException
will be thrown if the
database locking failure causes only statement-level
rollback.
refresh
in interface EntityManager
entity
- entity instancelockModeType
- lock modepublic void refresh(Object entity, LockModeType lockModeType, Map<String,Object> properties)
EntityManager
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
PessimisticLockException
will be thrown if the database
locking failure causes transaction-level rollback
LockTimeoutException
will be thrown if the database
locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
refresh
in interface EntityManager
entity
- entity instancelockModeType
- lock modeproperties
- standard and vendor-specific properties
and hintspublic void detach(Object entity)
EntityManager
detach
in interface EntityManager
entity
- entity instancepublic LockModeType getLockMode(Object entity)
EntityManager
getLockMode
in interface EntityManager
entity
- entity instancepublic void setProperty(String propertyName, Object value)
EntityManager
setProperty
in interface EntityManager
propertyName
- name of property or hintvalue
- value for property or hintpublic Map<String,Object> getProperties()
EntityManager
getProperties
in interface EntityManager
protected CriteriaCompiler criteriaCompiler()
public <T> QueryImplementor<T> createQuery(CriteriaQuery<T> criteriaQuery)
EntityManager
TypedQuery
for executing a
criteria query.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface Session
criteriaQuery
- a criteria query objectpublic QueryImplementor createQuery(CriteriaUpdate criteriaUpdate)
EntityManager
Query
for executing a criteria
update query.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface Session
criteriaUpdate
- a criteria update query objectpublic QueryImplementor createQuery(CriteriaDelete criteriaDelete)
EntityManager
Query
for executing a criteria
delete query.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface Session
criteriaDelete
- a criteria delete query objectprotected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition namedQueryDefinition)
initQueryFromNamedDefinition
in class AbstractSharedSessionContract
public StoredProcedureQuery createNamedStoredProcedureQuery(String name)
EntityManager
StoredProcedureQuery
for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
If the stored procedure returns one or more result sets, any result set will be returned as a list of type Object[].
createNamedStoredProcedureQuery
in interface EntityManager
name
- name assigned to the stored procedure query
in metadatapublic StoredProcedureQuery createStoredProcedureQuery(String procedureName)
EntityManager
StoredProcedureQuery
for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
If the stored procedure returns one or more result sets, any result set will be returned as a list of type Object[].
createStoredProcedureQuery
in interface EntityManager
procedureName
- name of the stored procedure in the
databasepublic StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses)
EntityManager
StoredProcedureQuery
for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
The resultClass
arguments must be specified in the order in
which the result sets will be returned by the stored procedure
invocation.
createStoredProcedureQuery
in interface EntityManager
procedureName
- name of the stored procedure in the
databaseresultClasses
- classes to which the result sets
produced by the stored procedure are to
be mappedpublic StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings)
EntityManager
StoredProcedureQuery
for executing a
stored procedure in the database.
Parameters must be registered before the stored procedure can be executed.
The resultSetMapping
arguments must be specified in the order
in which the result sets will be returned by the stored
procedure invocation.
createStoredProcedureQuery
in interface EntityManager
procedureName
- name of the stored procedure in the
databaseresultSetMappings
- the names of the result set mappings
to be used in mapping result sets
returned by the stored procedurepublic void joinTransaction()
EntityManager
This method should be called on a JTA application
managed entity manager that was created outside the scope
of the active transaction or on an entity manager of type
SynchronizationType.UNSYNCHRONIZED
to associate
it with the current JTA transaction.
joinTransaction
in interface EntityManager
public boolean isJoinedToTransaction()
EntityManager
isJoinedToTransaction
in interface EntityManager
public <T> T unwrap(Class<T> clazz)
EntityManager
EntityManager
implementation does not support the specified class, the
PersistenceException
is thrown.unwrap
in interface EntityManager
clazz
- the class of the object to be returned. This is
normally either the underlying EntityManager
implementation
class or an interface that it implements.public Object getDelegate()
EntityManager
EntityManager
,
if available. The result of this method is implementation
specific.
The unwrap
method is to be preferred for new applications.
getDelegate
in interface EntityManager
public SessionFactoryImplementor getEntityManagerFactory()
EntityManager
getEntityManagerFactory
in interface EntityManager
public CriteriaBuilder getCriteriaBuilder()
EntityManager
CriteriaBuilder
for the creation of
CriteriaQuery
objects.getCriteriaBuilder
in interface EntityManager
public MetamodelImplementor getMetamodel()
EntityManager
Metamodel
interface for access to the
metamodel of the persistence unit.getMetamodel
in interface EntityManager
public <T> EntityGraph<T> createEntityGraph(Class<T> rootType)
EntityManager
createEntityGraph
in interface EntityManager
rootType
- class of entity graphpublic EntityGraph<?> createEntityGraph(String graphName)
EntityManager
createEntityGraph
in interface EntityManager
graphName
- name of an entity graphpublic EntityGraph<?> getEntityGraph(String graphName)
EntityManager
getEntityGraph
in interface EntityManager
graphName
- name of an existing entity graphpublic <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
EntityManager
getEntityGraphs
in interface EntityManager
entityClass
- entity classCopyright © 2019 JBoss by Red Hat. All rights reserved.