public class SessionDelegatorBaseImpl extends Object implements SessionImplementor
SessionImplementor
and
a Session
. This is useful for custom implementations of this
API so that only some methods need to be overridden
(Used by Hibernate Search).Session.LockRequest
LobCreationContext.Callback<T>
HibernateEntityManagerImplementor.QueryOptions
Modifier and Type | Field and Description |
---|---|
protected SessionImplementor |
delegate |
Constructor and Description |
---|
SessionDelegatorBaseImpl(SessionImplementor delegate) |
SessionDelegatorBaseImpl(SessionImplementor delegate,
Session session)
Deprecated.
(since 5.3) SessionDelegatorBaseImpl should take just one argument, the SessionImplementor.
Use the
SessionDelegatorBaseImpl(SessionImplementor) form instead |
Modifier and Type | Method and Description |
---|---|
Transaction |
accessTransaction()
Provides access to the underlying transaction or creates a new transaction if
one does not already exist or is active.
|
void |
addEventListeners(SessionEventListener... listeners)
Add one or more listeners to the Session
|
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.
|
void |
beforeTransactionCompletion()
A before-completion callback to the owner.
|
Transaction |
beginTransaction()
Begin a unit of work and return the associated
Transaction object. |
String |
bestGuessEntityName(Object object)
The best guess entity name for an entity not in an association
|
LockOptions |
buildLockOptions(LockModeType lockModeType,
Map<String,Object> properties)
Given a JPA
LockModeType and properties, build a Hibernate
LockOptions |
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 |
checkOpen()
Performs a check whether the Session is open, and if not:
marks current transaction (if one) for rollback only
throws an IllegalStateException (JPA defines the exception type)
|
void |
checkOpen(boolean markForRollbackIfClosed)
Performs a check whether the Session is open, and if not:
if
markForRollbackIfClosed is true, marks current transaction (if one) for rollback only
throws an IllegalStateException (JPA defines the exception type)
|
void |
clear()
Completely clear the session.
|
void |
close()
End the session by releasing the JDBC connection and cleaning up.
|
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. |
QueryImplementor |
createNamedQuery(String name)
The JPA-defined named query creation method.
|
<T> QueryImplementor<T> |
createNamedQuery(String name,
Class<T> resultClass)
The JPA-defined named, typed query creation method.
|
StoredProcedureQuery |
createNamedStoredProcedureQuery(String name)
Create an instance of
StoredProcedureQuery for executing a
stored procedure in the database. |
NativeQueryImplementor |
createNativeQuery(String sqlString)
Create a NativeQuery instance for the given native (SQL) query
|
NativeQueryImplementor |
createNativeQuery(String sqlString,
Class resultClass)
Create a NativeQuery instance for the given native (SQL) query using
implicit mapping to the specified Java type.
|
NativeQueryImplementor |
createNativeQuery(String sqlString,
String resultSetMapping)
Create a NativeQuery instance for the given native (SQL) query using
implicit mapping to the specified Java type.
|
QueryImplementor |
createQuery(CriteriaDelete deleteQuery)
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 updateQuery)
Create an instance of
Query for executing a criteria
update query. |
QueryImplementor |
createQuery(String queryString)
Create a
Query instance for the given HQL/JPQL query string. |
<T> QueryImplementor<T> |
createQuery(String queryString,
Class<T> resultType)
Create a typed
Query instance for the given HQL/JPQL query string. |
<T> QueryImplementor<T> |
createQuery(String jpaqlString,
Class<T> resultClass,
Selection selection,
HibernateEntityManagerImplementor.QueryOptions queryOptions)
Used during "compiling" a JPA criteria query.
|
NativeQueryImplementor |
createSQLQuery(String queryString)
Create a
NativeQuery instance for the given SQL query string. |
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 SessionImplementor |
delegate()
Returns the underlying delegate.
|
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 child,
boolean isCascadeDeleteEnabled,
Set transientEntities) |
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 this instance from the session cache.
|
<T> T |
execute(LobCreationContext.Callback<T> callback)
Execute the given callback, making sure it has access to a viable JDBC
Connection . |
int |
executeNativeUpdate(NativeSQLQuerySpecification specification,
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 lockMode)
Find by primary key and lock.
|
<T> T |
find(Class<T> entityClass,
Object primaryKey,
LockModeType lockMode,
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 e) |
EntityKey |
generateEntityKey(Serializable id,
EntityPersister persister)
Hide the changing requirements of entity key creation
|
<T> T |
get(Class<T> theClass,
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> theClass,
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> theClass,
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() |
CacheMode |
getCacheMode()
Get the current cache mode.
|
CacheTransactionSynchronization |
getCacheTransactionSynchronization()
The current CacheTransactionContext associated with the Session.
|
Serializable |
getContextEntityIdentifier(Object object)
Return the identifier of the persistent object, or null if
not 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()
This is an implementation of EntityManager#getDelegate().
|
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.
|
EntityManagerFactory |
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
|
SessionEventListenerManager |
getEventListenerManager() |
ExceptionConverter |
getExceptionConverter() |
SessionFactoryImplementor |
getFactory()
Get the creating SessionFactoryImplementor
|
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.
|
Interceptor |
getInterceptor()
Retrieves the interceptor currently in use by this event source.
|
Integer |
getJdbcBatchSize()
Get the Session-level JDBC batch size for the current Session.
|
JdbcConnectionAccess |
getJdbcConnectionAccess() |
JdbcCoordinator |
getJdbcCoordinator() |
JdbcServices |
getJdbcServices() |
JdbcSessionContext |
getJdbcSessionContext() |
TimeZone |
getJdbcTimeZone()
The JDBC
TimeZone used when persisting Timestamp and DateTime properties into the database. |
LoadQueryInfluencers |
getLoadQueryInfluencers()
Get the load query influencers associated with this session.
|
LobCreator |
getLobCreator()
Obtain access to the
LobCreator |
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 |
Metamodel |
getMetamodel()
Return an instance of
Metamodel interface for access to the
metamodel of the persistence unit. |
NativeQueryImplementor |
getNamedNativeQuery(String name)
Get a NativeQuery instance for a named native SQL query
|
ProcedureCall |
getNamedProcedureCall(String name)
Gets a ProcedureCall based on a named template
|
QueryImplementor |
getNamedQuery(String name)
Create a
Query instance for the named query. |
NativeQueryImplementor |
getNamedSQLQuery(String name)
Get a NativeQuery instance for a named native SQL query
|
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.
|
UUID |
getSessionIdentifier()
A UUID associated with each Session.
|
SessionStatistics |
getStatistics()
Get the statistics for this session.
|
String |
getTenantIdentifier()
Obtain the tenant identifier associated with this session.
|
long |
getTimestamp() |
Transaction |
getTransaction()
Get the
Transaction instance associated with this session. |
TransactionCoordinator |
getTransactionCoordinator()
Obtain the builder for TransactionCoordinator instances
|
long |
getTransactionStartTimestamp()
A "timestamp" at or before the start of the current transaction.
|
TypeHelper |
getTypeHelper()
Convenience access to the
TypeHelper associated with this session's SessionFactory . |
String |
guessEntityName(Object entity)
The guessed entity name for an entity not in an association
|
Object |
immediateLoad(String entityName,
Serializable id)
Load an instance immediately.
|
void |
initializeCollection(PersistentCollection collection,
boolean writing)
Initialize the collection (if not already initialized)
|
Object |
instantiate(EntityPersister persister,
Serializable id) |
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 |
isClosed()
Checks whether the session is closed.
|
boolean |
isConnected()
Check if the session is currently connected.
|
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 |
isOpenOrWaitingForAutoClose()
Checks whether the session is open or is waiting for auto-close
|
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:
|
boolean |
isTransactionInProgress()
Does this Session have an active Hibernate transaction
or is there a JTA transaction in progress?
|
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(NativeSQLQuerySpecification spec,
QueryParameters queryParameters)
Execute a native SQL query, and return the results as a fully built list.
|
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> 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(Object entity,
LockModeType lockMode)
Lock an entity instance that is contained in the persistence
context with the specified lock mode type.
|
void |
lock(Object entity,
LockModeType lockMode,
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.
|
void |
markForRollbackOnly()
Marks current transaction (if one) for rollback only
|
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) |
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 createdAlready) |
void |
persistOnFlush(String entityName,
Object object,
Map copiedAlready) |
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 entity,
LockModeType lockMode)
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 lockMode,
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) |
SqlTypeDescriptor |
remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
Allow remapping of descriptors for dealing with sql type.
|
void |
remove(Object entity)
Remove the entity instance.
|
void |
removeOrphanBeforeUpdates(String entityName,
Object child) |
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
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 object)
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(NativeSQLQuerySpecification spec,
QueryParameters queryParameters)
Execute a native SQL query, and return the results as a scrollable result.
|
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 |
setCacheMode(CacheMode cm)
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 fm)
Set the flush mode for this session.
|
void |
setFlushMode(FlushModeType flushModeType)
Set the flush mode that applies to all objects contained
in the persistence context.
|
void |
setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.
|
void |
setJdbcBatchSize(Integer jdbcBatchSize)
Set the Session-level JDBC batch size.
|
void |
setProperty(String propertyName,
Object value)
Set an entity manager property or hint.
|
void |
setReadOnly(Object entityOrProxy,
boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only
object to modifiable mode.
|
boolean |
shouldAutoClose() |
boolean |
shouldAutoJoinTransaction()
Indicates whether an active transaction should be automatically joined.
|
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 |
<T> T |
unwrap(Class<T> cls)
Return an object of the specified type to allow access to the
provider-specific API.
|
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.
|
boolean |
useStreamForLobBinding()
Should streams be used for binding LOB values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfiguredJdbcBatchSize
protected final SessionImplementor delegate
@Deprecated public SessionDelegatorBaseImpl(SessionImplementor delegate, Session session)
SessionDelegatorBaseImpl(SessionImplementor)
form insteadpublic SessionDelegatorBaseImpl(SessionImplementor delegate)
protected SessionImplementor delegate()
getDelegate()
method coming from the EntityManager interface which returns the current session.getDelegate()
public <T> T execute(LobCreationContext.Callback<T> callback)
LobCreationContext
Connection
.execute
in interface LobCreationContext
T
- The Java type of the type of LOB being created. One of Blob
,
Clob
, NClob
callback
- The callback to execute .public String getTenantIdentifier()
SharedSessionContract
getTenantIdentifier
in interface SharedSessionContractImplementor
getTenantIdentifier
in interface SharedSessionContract
null
public UUID getSessionIdentifier()
SharedSessionContractImplementor
getSessionIdentifier
in interface SharedSessionContractImplementor
public JdbcConnectionAccess getJdbcConnectionAccess()
getJdbcConnectionAccess
in interface JdbcSessionOwner
public EntityKey generateEntityKey(Serializable id, EntityPersister persister)
SharedSessionContractImplementor
generateEntityKey
in interface SharedSessionContractImplementor
id
- The entity idpersister
- The entity persisterpublic Interceptor getInterceptor()
SharedSessionContractImplementor
getInterceptor
in interface SharedSessionContractImplementor
public void setAutoClear(boolean enabled)
SharedSessionContractImplementor
setAutoClear
in interface SharedSessionContractImplementor
public boolean isTransactionInProgress()
SharedSessionContractImplementor
isTransactionInProgress
in interface SharedSessionContractImplementor
isTransactionInProgress
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 LockOptions buildLockOptions(LockModeType lockModeType, Map<String,Object> properties)
HibernateEntityManagerImplementor
LockModeType
and properties, build a Hibernate
LockOptions
buildLockOptions
in interface HibernateEntityManagerImplementor
lockModeType
- the requested LockModeTypeproperties
- 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 initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException
SharedSessionContractImplementor
initializeCollection
in interface SharedSessionContractImplementor
HibernateException
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException
SharedSessionContractImplementor
internalLoad
in interface SharedSessionContractImplementor
HibernateException
public Object immediateLoad(String entityName, Serializable id) throws HibernateException
SharedSessionContractImplementor
immediateLoad
in interface SharedSessionContractImplementor
HibernateException
public long getTimestamp()
getTimestamp
in interface SharedSessionContractImplementor
public SessionFactoryImplementor getFactory()
SharedSessionContractImplementor
getFactory
in interface SharedSessionContractImplementor
getFactory
in interface HibernateEntityManagerFactoryAware
getFactory
in interface QueryProducerImplementor
public List list(String query, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
list
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 ScrollableResultsImplementor scroll(Criteria criteria, ScrollMode scrollMode)
SharedSessionContractImplementor
scroll
in interface SharedSessionContractImplementor
public List list(Criteria criteria)
SharedSessionContractImplementor
list
in interface SharedSessionContractImplementor
public List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
listFilter
in interface SharedSessionContractImplementor
HibernateException
public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
iterateFilter
in interface SharedSessionContractImplementor
HibernateException
public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException
SharedSessionContractImplementor
getEntityPersister
in interface SharedSessionContractImplementor
entityName
- optional entity nameobject
- the entity instanceHibernateException
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
SharedSessionContractImplementor
getEntityUsingInterceptor
in interface SharedSessionContractImplementor
HibernateException
public Serializable getContextEntityIdentifier(Object object)
SharedSessionContractImplementor
getContextEntityIdentifier
in interface SharedSessionContractImplementor
public String bestGuessEntityName(Object object)
SharedSessionContractImplementor
bestGuessEntityName
in interface SharedSessionContractImplementor
public String guessEntityName(Object entity) throws HibernateException
SharedSessionContractImplementor
guessEntityName
in interface SharedSessionContractImplementor
HibernateException
public Object instantiate(String entityName, Serializable id) throws HibernateException
SharedSessionContractImplementor
instantiate
in interface SharedSessionContractImplementor
HibernateException
public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
listCustomQuery
in interface SharedSessionContractImplementor
HibernateException
public ScrollableResultsImplementor scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
scrollCustomQuery
in interface SharedSessionContractImplementor
HibernateException
public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
list
in interface SharedSessionContractImplementor
spec
- The specification of the native SQL query to execute.queryParameters
- The parameters by which to perform the execution.HibernateException
public ScrollableResultsImplementor scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
scroll
in interface SharedSessionContractImplementor
spec
- The specification of the native SQL query to execute.queryParameters
- The parameters by which to perform the execution.HibernateException
public int getDontFlushFromFind()
getDontFlushFromFind
in interface SharedSessionContractImplementor
public PersistenceContext getPersistenceContext()
SharedSessionContractImplementor
getPersistenceContext
in interface SharedSessionContractImplementor
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
executeUpdate
in interface SharedSessionContractImplementor
HibernateException
public int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException
SharedSessionContractImplementor
executeNativeUpdate
in interface SharedSessionContractImplementor
HibernateException
public CacheMode getCacheMode()
Session
getCacheMode
in interface SharedSessionContractImplementor
getCacheMode
in interface QueryProducerImplementor
getCacheMode
in interface Session
public void setCacheMode(CacheMode cm)
Session
setCacheMode
in interface SharedSessionContractImplementor
setCacheMode
in interface Session
cm
- The new cache mode.public boolean isOpen()
SharedSessionContract
isOpen
in interface EntityManager
isOpen
in interface SharedSessionContract
public boolean isConnected()
SharedSessionContract
isConnected
in interface SharedSessionContract
public void checkOpen(boolean markForRollbackIfClosed)
SharedSessionContractImplementor
markForRollbackIfClosed
is true, marks current transaction (if one) for rollback onlycheckOpen
in interface SharedSessionContractImplementor
checkOpen
in interface HibernateEntityManagerImplementor
markForRollbackIfClosed
- If the EM is closed, should the transaction (if one) be marked for rollback?public void markForRollbackOnly()
SharedSessionContractImplementor
markForRollbackOnly
in interface SharedSessionContractImplementor
markForRollbackOnly
in interface HibernateEntityManagerImplementor
public long getTransactionStartTimestamp()
SharedSessionContractImplementor
getTransactionStartTimestamp
in interface SharedSessionContractImplementor
public FlushModeType getFlushMode()
Session
FlushModeType
rather than Hibernate's FlushMode
. For
the former behavior, use Session.getHibernateFlushMode()
instead.getFlushMode
in interface EntityManager
getFlushMode
in interface SharedSessionContractImplementor
getFlushMode
in interface Session
public void setFlushMode(FlushModeType flushModeType)
EntityManager
setFlushMode
in interface EntityManager
flushModeType
- flush modepublic void setHibernateFlushMode(FlushMode flushMode)
Session
FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).setHibernateFlushMode
in interface SharedSessionContractImplementor
setHibernateFlushMode
in interface Session
flushMode
- the new flush modepublic FlushMode getHibernateFlushMode()
Session
getHibernateFlushMode
in interface SharedSessionContractImplementor
getHibernateFlushMode
in interface QueryProducerImplementor
getHibernateFlushMode
in interface Session
public void setFlushMode(FlushMode fm)
Session
FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).setFlushMode
in interface SharedSessionContractImplementor
setFlushMode
in interface Session
fm
- the new flush modepublic void lock(Object entity, LockModeType lockMode)
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 instancelockMode
- lock modepublic void lock(Object entity, LockModeType lockMode, 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 instancelockMode
- lock modeproperties
- standard and vendor-specific properties
and hintspublic Connection connection()
connection
in interface SharedSessionContractImplementor
public void flush()
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
public boolean isEventSource()
isEventSource
in interface SharedSessionContractImplementor
public void afterScrollOperation()
afterScrollOperation
in interface SharedSessionContractImplementor
public TransactionCoordinator getTransactionCoordinator()
JdbcSessionOwner
getTransactionCoordinator
in interface JdbcSessionOwner
public JdbcCoordinator getJdbcCoordinator()
getJdbcCoordinator
in interface SharedSessionContractImplementor
public JdbcServices getJdbcServices()
getJdbcServices
in interface SharedSessionContractImplementor
public JdbcSessionContext getJdbcSessionContext()
getJdbcSessionContext
in interface JdbcSessionOwner
public boolean isClosed()
SharedSessionContractImplementor
SharedSessionContract.isOpen()
as this method does not attempt any JTA synchronization
registration, where as SharedSessionContract.isOpen()
does; which makes this one
nicer to use for most internal purposes.isClosed
in interface SharedSessionContractImplementor
true
if the session is closed; false
otherwise.public void checkOpen()
SharedSessionContractImplementor
checkOpen
in interface SharedSessionContractImplementor
public boolean isOpenOrWaitingForAutoClose()
SharedSessionContractImplementor
isOpenOrWaitingForAutoClose
in interface SharedSessionContractImplementor
true
if the session is closed or if it's waiting for auto-close; false
otherwise.public boolean shouldAutoClose()
shouldAutoClose
in interface SharedSessionContractImplementor
public boolean isAutoCloseSessionEnabled()
isAutoCloseSessionEnabled
in interface SharedSessionContractImplementor
public boolean isQueryParametersValidationEnabled()
isQueryParametersValidationEnabled
in interface SharedSessionContractImplementor
public boolean shouldAutoJoinTransaction()
TransactionCoordinatorBuilder.Options
shouldAutoJoinTransaction
in interface TransactionCoordinatorBuilder.Options
true
indicates the active transaction should be auto joined; false
indicates it should not (until TransactionCoordinator.explicitJoin()
is called).public LoadQueryInfluencers getLoadQueryInfluencers()
SharedSessionContractImplementor
getLoadQueryInfluencers
in interface SharedSessionContractImplementor
public ExceptionConverter getExceptionConverter()
getExceptionConverter
in interface SharedSessionContractImplementor
public SessionEventListenerManager getEventListenerManager()
getEventListenerManager
in interface SharedSessionContractImplementor
public Transaction accessTransaction()
SharedSessionContractImplementor
accessTransaction
in interface SharedSessionContractImplementor
public Transaction beginTransaction()
SharedSessionContract
Transaction
object. If a new underlying transaction is
required, begin the transaction. Otherwise continue the new work in the context of the existing underlying
transaction.beginTransaction
in interface SharedSessionContract
SharedSessionContract.getTransaction()
public Transaction getTransaction()
SharedSessionContract
Transaction
instance associated with this session. The concrete type of the returned
Transaction
object is determined by the hibernate.transaction_factory
property.getTransaction
in interface EntityManager
getTransaction
in interface SharedSessionContract
public void startTransactionBoundary()
JdbcSessionOwner
Transaction
API or via registration
of Hibernate's JTA Synchronization impl with a JTA TransactionstartTransactionBoundary
in interface JdbcSessionOwner
public CacheTransactionSynchronization getCacheTransactionSynchronization()
SharedSessionContractImplementor
null
when the Session is not currently part of a transaction.getCacheTransactionSynchronization
in interface SharedSessionContractImplementor
public void afterTransactionBegin()
JdbcSessionOwner
afterTransactionBegin
in interface JdbcSessionOwner
public void beforeTransactionCompletion()
JdbcSessionOwner
beforeTransactionCompletion
in interface JdbcSessionOwner
public void afterTransactionCompletion(boolean successful, boolean delayed)
JdbcSessionOwner
afterTransactionCompletion
in interface JdbcSessionOwner
successful
- Was the transaction successful?delayed
- Is this a delayed after transaction completion call (aka after a timeout)?public void flushBeforeTransactionCompletion()
flushBeforeTransactionCompletion
in interface JdbcSessionOwner
public EntityManagerFactory getEntityManagerFactory()
EntityManager
getEntityManagerFactory
in interface EntityManager
public CriteriaBuilder getCriteriaBuilder()
EntityManager
CriteriaBuilder
for the creation of
CriteriaQuery
objects.getCriteriaBuilder
in interface EntityManager
public Metamodel 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 classpublic QueryImplementor getNamedQuery(String name)
QueryProducer
Query
instance for the named query.getNamedQuery
in interface SessionImplementor
getNamedQuery
in interface QueryProducer
getNamedQuery
in interface QueryProducerImplementor
getNamedQuery
in interface Session
name
- the name of a pre-defined, named querypublic NativeQueryImplementor getNamedSQLQuery(String name)
QueryProducer
getNamedSQLQuery
in interface SessionImplementor
getNamedSQLQuery
in interface QueryProducer
getNamedSQLQuery
in interface QueryProducerImplementor
name
- The name of the pre-defined querypublic NativeQueryImplementor getNamedNativeQuery(String name)
QueryProducer
getNamedNativeQuery
in interface SessionImplementor
getNamedNativeQuery
in interface QueryProducer
getNamedNativeQuery
in interface QueryProducerImplementor
name
- The name of the pre-defined querypublic QueryImplementor createQuery(String queryString)
QueryProducer
Query
instance for the given HQL/JPQL query string.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface QueryProducer
createQuery
in interface QueryProducerImplementor
createQuery
in interface Session
queryString
- The HQL/JPQL queryEntityManager.createQuery(String)
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> resultType)
QueryProducer
Query
instance for the given HQL/JPQL query string.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface QueryProducer
createQuery
in interface QueryProducerImplementor
createQuery
in interface Session
queryString
- The HQL/JPQL queryresultType
- the type of the query resultEntityManager.createQuery(String,Class)
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 updateQuery)
EntityManager
Query
for executing a criteria
update query.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface Session
updateQuery
- a criteria update query objectpublic QueryImplementor createQuery(CriteriaDelete deleteQuery)
EntityManager
Query
for executing a criteria
delete query.createQuery
in interface EntityManager
createQuery
in interface SessionImplementor
createQuery
in interface Session
deleteQuery
- a criteria delete query objectpublic QueryImplementor createNamedQuery(String name)
QueryProducer
createNamedQuery
in interface EntityManager
createNamedQuery
in interface SessionImplementor
createNamedQuery
in interface QueryProducer
createNamedQuery
in interface QueryProducerImplementor
name
- the name of a pre-defined, named queryEntityManager.createNamedQuery(String)
public <T> QueryImplementor<T> createNamedQuery(String name, Class<T> resultClass)
QueryProducer
createNamedQuery
in interface EntityManager
createNamedQuery
in interface SessionImplementor
createNamedQuery
in interface QueryProducer
createNamedQuery
in interface QueryProducerImplementor
createNamedQuery
in interface Session
name
- the name of a query defined in metadataresultClass
- the type of the query resultEntityManager.createNamedQuery(String,Class)
public NativeQueryImplementor createNativeQuery(String sqlString)
QueryProducer
createNativeQuery
in interface EntityManager
createNativeQuery
in interface SessionImplementor
createNativeQuery
in interface QueryProducer
createNativeQuery
in interface QueryProducerImplementor
sqlString
- a native SQL query stringEntityManager.createNativeQuery(String)
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass)
QueryProducer
createNativeQuery
in interface EntityManager
createNativeQuery
in interface SessionImplementor
createNativeQuery
in interface QueryProducer
createNativeQuery
in interface QueryProducerImplementor
sqlString
- Native (SQL) query stringresultClass
- The Java type to map results toEntityManager.createNativeQuery(String,Class)
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMapping)
QueryProducer
createNativeQuery
in interface EntityManager
createNativeQuery
in interface SessionImplementor
createNativeQuery
in interface QueryProducer
createNativeQuery
in interface QueryProducerImplementor
sqlString
- Native (SQL) query stringresultSetMapping
- The explicit (named) result mappingEntityManager.createNativeQuery(String,Class)
,
SqlResultSetMapping
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> cls)
EntityManager
EntityManager
implementation does not support the specified class, the
PersistenceException
is thrown.unwrap
in interface EntityManager
cls
- 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()
To get the underlying delegate, use delegate()
instead.
getDelegate
in interface EntityManager
delegate()
public NativeQueryImplementor createSQLQuery(String queryString)
QueryProducer
NativeQuery
instance for the given SQL query string.createSQLQuery
in interface SessionImplementor
createSQLQuery
in interface QueryProducer
createSQLQuery
in interface QueryProducerImplementor
createSQLQuery
in interface Session
queryString
- The SQL querypublic ProcedureCall getNamedProcedureCall(String name)
SharedSessionContract
getNamedProcedureCall
in interface SharedSessionContract
name
- The name given to the templateNamedStoredProcedureQuery
public ProcedureCall createStoredProcedureCall(String procedureName)
SharedSessionContract
createStoredProcedureCall
in interface SharedSessionContract
procedureName
- The name of the procedure.public ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses)
SharedSessionContract
createStoredProcedureCall
in interface SharedSessionContract
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
SharedSessionContract
createStoredProcedureCall
in interface SharedSessionContract
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the resultspublic 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(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)
SharedSessionContract
Criteria
instance for the given entity name.createCriteria
in interface SharedSessionContract
entityName
- The entity namepublic 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 SharedSessionBuilder sessionWithOptions()
Session
Session
builder with the ability to grab certain information from this session.sessionWithOptions
in interface Session
public SessionFactoryImplementor getSessionFactory()
Session
getSessionFactory
in interface SessionImplementor
getSessionFactory
in interface Session
SessionFactory
public void close() throws HibernateException
SharedSessionContract
close
in interface Closeable
close
in interface AutoCloseable
close
in interface EntityManager
close
in interface SharedSessionContract
HibernateException
- Indicates problems cleaning up.public void cancelQuery() throws HibernateException
Session
cancelQuery
in interface Session
HibernateException
- There was a problem canceling the querypublic boolean isDirty() throws HibernateException
Session
isDirty
in interface Session
HibernateException
- could not perform dirtying checkingpublic boolean isDefaultReadOnly()
Session
isDefaultReadOnly
in interface Session
Session.isReadOnly(Object)
public void setDefaultReadOnly(boolean readOnly)
Session
setDefaultReadOnly
in interface Session
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)
public Serializable getIdentifier(Object object)
Session
getIdentifier
in interface Session
object
- a persistent instancepublic boolean contains(String entityName, Object object)
Session
public boolean contains(Object object)
EntityManager
contains
in interface EntityManager
object
- 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
public void evict(Object object)
Session
public <T> T load(Class<T> theClass, Serializable id, LockMode lockMode)
Session
Session.load(Class, Serializable, LockOptions)
load
in interface Session
theClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock levelSession.load(Class, Serializable, LockOptions)
public <T> T load(Class<T> theClass, Serializable id, LockOptions lockOptions)
Session
public Object load(String entityName, Serializable id, LockMode lockMode)
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 levelSession.load(String, Serializable, LockOptions)
public Object load(String entityName, Serializable id, LockOptions lockOptions)
Session
public <T> T load(Class<T> theClass, Serializable id)
Session
public Object load(String entityName, Serializable id)
Session
public void load(Object object, Serializable id)
Session
public void replicate(Object object, ReplicationMode replicationMode)
Session
cascade="replicate"
public void replicate(String entityName, Object object, ReplicationMode replicationMode)
Session
cascade="replicate"
public Serializable save(Object object)
Session
cascade="save-update"
public Serializable save(String entityName, Object object)
Session
cascade="save-update"
public void saveOrUpdate(Object object)
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 stateSession.save(java.lang.Object)
,
Session.update(Object object)
public void saveOrUpdate(String entityName, Object object)
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 nameobject
- a transient or detached instance containing new or updated stateSession.save(String,Object)
,
Session.update(String,Object)
public void update(Object object)
Session
cascade="save-update"
public void update(String entityName, Object object)
Session
cascade="save-update"
public Object merge(Object object)
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 copiedpublic Object merge(String entityName, Object object)
Session
cascade="merge"
The semantics of this method are defined by JSR-220.public void persist(Object object)
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 persistentpublic 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 lockMode)
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 keylockMode
- lock modepublic <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, 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 keylockMode
- 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 persist(String entityName, Object object)
Session
cascade="persist"
The semantics of this method are defined by JSR-220.public void delete(Object object)
Session
cascade="delete"
public void delete(String entityName, Object object)
Session
cascade="delete"
public void lock(Object object, LockMode lockMode)
Session
Session.LockRequest.lock(Object)
via Session.buildLockRequest(LockOptions)
lock
in interface Session
object
- a persistent or transient instancelockMode
- the lock levelSession.buildLockRequest(LockOptions)
,
Session.LockRequest.lock(Object)
public void lock(String entityName, Object object, LockMode lockMode)
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 levelSession.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 refresh(Object object)
Session
refresh
in interface EntityManager
refresh
in interface Session
object
- a persistent or detached instancepublic 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 lockMode)
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 instancelockMode
- lock modepublic void refresh(Object entity, LockModeType lockMode, 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 instancelockMode
- lock modeproperties
- standard and vendor-specific properties
and hintspublic void refresh(String entityName, Object object)
Session
public void refresh(Object object, LockMode lockMode)
Session
Session.refresh(Object, LockOptions)
refresh
in interface Session
object
- a persistent or detached instancelockMode
- the lock mode to useSession.refresh(Object, LockOptions)
public void refresh(Object object, LockOptions lockOptions)
Session
public void refresh(String entityName, Object object, LockOptions lockOptions)
Session
public LockMode getCurrentLockMode(Object object)
Session
getCurrentLockMode
in interface Session
object
- a persistent instancepublic 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 void clear()
Session
clear
in interface EntityManager
clear
in interface Session
public void detach(Object entity)
EntityManager
detach
in interface EntityManager
entity
- entity instancepublic <T> T get(Class<T> theClass, Serializable id)
Session
public <T> T get(Class<T> theClass, Serializable id, LockMode lockMode)
Session
Session.get(Class, Serializable, LockOptions)
get
in interface Session
theClass
- The entity typeid
- an identifierlockMode
- the lock modeSession.get(Class, Serializable, LockOptions)
public <T> T get(Class<T> theClass, Serializable id, LockOptions lockOptions)
Session
public Object get(String entityName, Serializable id)
Session
public Object get(String entityName, Serializable id, LockMode lockMode)
Session
Session.get(String, Serializable, LockOptions)
get
in interface Session
entityName
- the entity nameid
- an identifierlockMode
- the lock modeSession.get(String, Serializable, LockOptions)
public Object get(String entityName, Serializable id, LockOptions lockOptions)
Session
public String getEntityName(Object object)
Session
getEntityName
in interface Session
object
- a persistent entitypublic IdentifierLoadAccess byId(String entityName)
Session
IdentifierLoadAccess
instance to retrieve the specified entity type 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 <T> IdentifierLoadAccess<T> byId(Class<T> entityClass)
Session
IdentifierLoadAccess
instance to retrieve the specified entity by
primary key.public 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 Filter enableFilter(String filterName)
Session
enableFilter
in interface Session
filterName
- The name of the filter to be enabled.public Filter getEnabledFilter(String filterName)
Session
getEnabledFilter
in interface Session
filterName
- The name of the filter to be retrieved.public void disableFilter(String filterName)
Session
disableFilter
in interface Session
filterName
- The name of the filter to be disabled.public SessionStatistics getStatistics()
Session
getStatistics
in interface Session
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 entityOrProxy, boolean readOnly)
Session
setReadOnly
in interface Session
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)
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 Connection disconnect()
Session
disconnect
in interface Session
null
Session.reconnect(Connection)
public void reconnect(Connection connection)
Session
reconnect
in interface Session
connection
- a JDBC connectionSession.disconnect()
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 addEventListeners(SessionEventListener... listeners)
Session
addEventListeners
in interface Session
listeners
- The listener(s) to addpublic boolean isFlushBeforeCompletionEnabled()
isFlushBeforeCompletionEnabled
in interface SessionImplementor
public ActionQueue getActionQueue()
getActionQueue
in interface SessionImplementor
public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException
instantiate
in interface SessionImplementor
HibernateException
public void forceFlush(EntityEntry e) throws HibernateException
forceFlush
in interface SessionImplementor
HibernateException
public void merge(String entityName, Object object, Map copiedAlready) throws HibernateException
merge
in interface SessionImplementor
HibernateException
public void persist(String entityName, Object object, Map createdAlready) throws HibernateException
persist
in interface SessionImplementor
HibernateException
public void persistOnFlush(String entityName, Object object, Map copiedAlready)
persistOnFlush
in interface SessionImplementor
public void refresh(String entityName, Object object, Map refreshedAlready) throws HibernateException
refresh
in interface SessionImplementor
HibernateException
public void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, Set transientEntities)
delete
in interface SessionImplementor
public void removeOrphanBeforeUpdates(String entityName, Object child)
removeOrphanBeforeUpdates
in interface SessionImplementor
public SessionImplementor getSession()
HibernateEntityManager
Session
used by this EntityManager
.getSession
in interface HibernateEntityManager
getSession
in interface HibernateEntityManagerImplementor
public boolean useStreamForLobBinding()
WrapperOptions
useStreamForLobBinding
in interface WrapperOptions
true
/false
public LobCreator getLobCreator()
WrapperOptions
LobCreator
getLobCreator
in interface WrapperOptions
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
WrapperOptions
remapSqlTypeDescriptor
in interface WrapperOptions
sqlTypeDescriptor
- The known descriptorpublic Integer getJdbcBatchSize()
SharedSessionContract
hibernate.default_batch_fetch_size
configuration property for the scope of the current Session
.getJdbcBatchSize
in interface JdbcSessionOwner
getJdbcBatchSize
in interface SharedSessionContract
SessionFactoryOptions.getJdbcBatchSize()
,
SessionFactoryBuilder.applyJdbcBatchSize(int)
public void setJdbcBatchSize(Integer jdbcBatchSize)
SharedSessionContract
hibernate.default_batch_fetch_size
configuration property for the scope of the current Session
.setJdbcBatchSize
in interface SharedSessionContract
jdbcBatchSize
- Session-level JDBC batch sizeSessionFactoryOptions.getJdbcBatchSize()
,
SessionFactoryBuilder.applyJdbcBatchSize(int)
public TimeZone getJdbcTimeZone()
WrapperOptions
TimeZone
used when persisting Timestamp and DateTime properties into the database.
This setting is used when storing timestamps using the PreparedStatement.setTimestamp(int, Timestamp, Calendar)
method.
This way, the storage TimeZone
can differ from the default JVM TimeZone given by TimeZone.getDefault()
.getJdbcTimeZone
in interface WrapperOptions
TimeZone
Copyright © 2019 JBoss by Red Hat. All rights reserved.