|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hibernate.internal.AbstractSessionImpl org.hibernate.internal.SessionImpl
public final class SessionImpl
Concrete implementation of a Session. Exposes two interfaces:
Session
to the applicationSessionImplementor
to other Hibernate components (SPI)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext |
---|
LobCreationContext.Callback<T> |
Nested classes/interfaces inherited from interface org.hibernate.Session |
---|
Session.LockRequest |
Field Summary |
---|
Fields inherited from class org.hibernate.internal.AbstractSessionImpl |
---|
factory |
Method Summary | ||
---|---|---|
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(TransactionImplementor hibernateTransaction)
|
|
void |
afterTransactionCompletion(TransactionImplementor hibernateTransaction,
boolean successful)
|
|
void |
applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges)
Apply non-flushed changes from a different session to this session. |
|
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(TransactionImplementor hibernateTransaction)
|
|
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 |
|
Session.LockRequest |
buildLockRequest(LockOptions lockOptions)
Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope. |
|
org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl |
byId(Class 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. |
|
NaturalIdLoadAccess |
byNaturalId(Class entityClass)
Create an NaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
|
NaturalIdLoadAccess |
byNaturalId(String entityName)
Create an NaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
|
SimpleNaturalIdLoadAccess |
bySimpleNaturalId(Class entityClass)
Create an SimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its simple (single attribute) natural id. |
|
SimpleNaturalIdLoadAccess |
bySimpleNaturalId(String entityName)
Create an SimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
|
void |
cancelQuery()
Cancel the execution of the current query. |
|
void |
clear()
Completely clear the session. |
|
Connection |
close()
End the session by releasing the JDBC connection and cleaning up. |
|
Connection |
connection()
|
|
boolean |
contains(Object object)
Check if this instance 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. |
|
Query |
createFilter(Object collection,
String queryString)
Create a Query instance for the given collection and filter string. |
|
Query |
createQuery(String queryString)
Create a Query instance for the given HQL query string. |
|
SQLQuery |
createSQLQuery(String sql)
Create a SQLQuery instance for the given SQL query string. |
|
void |
delete(Object object)
Delete a persistent object |
|
void |
delete(String entityName,
Object object)
Delete a persistent object (by explicit entity name) |
|
void |
delete(String entityName,
Object object,
boolean isCascadeDeleteEnabled,
Set transientEntities)
Delete a persistent object |
|
void |
disableFetchProfile(String name)
Disable a particular fetch profile on this session. |
|
void |
disableFilter(String filterName)
Disable the named filter for the current session. |
|
void |
disableTransactionAutoJoin()
Disable automatic transaction joining. |
|
Connection |
disconnect()
Disconnect the session from its underlying JDBC connection. |
|
|
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 persistant 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 |
|
void |
flush()
Force this session to flush. |
|
void |
forceFlush(EntityEntry entityEntry)
Force an immediate flush |
|
Object |
get(Class 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. |
|
Object |
get(Class 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. |
|
Object |
get(Class 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 |
|
CacheMode |
getCacheMode()
Get the current cache mode. |
|
ConnectionReleaseMode |
getConnectionReleaseMode()
Get the mode for releasing JDBC connection in effect for ths context. |
|
Serializable |
getContextEntityIdentifier(Object object)
Get the id value for an object that is actually associated with the session. |
|
LockMode |
getCurrentLockMode(Object object)
Determine the current lock mode of the given object. |
|
int |
getDontFlushFromFind()
|
|
Filter |
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name. |
|
Map |
getEnabledFilters()
Return the currently enabled filters. |
|
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 |
|
String |
getFetchProfile()
Get the internal fetch profile currently associated with this session. |
|
Type |
getFilterParameterType(String filterParameterName)
Retreive the type for a given filter parrameter. |
|
Object |
getFilterParameterValue(String filterParameterName)
Retreive the currently set value for a filter parameter. |
|
FlushMode |
getFlushMode()
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. |
|
LoadQueryInfluencers |
getLoadQueryInfluencers()
Get the load query influencers associated with this session. |
|
LobHelper |
getLobHelper()
Retrieve this session's helper/delegate for creating LOB instances. |
|
Query |
getNamedQuery(String queryName)
Create a Query instance for the named query string defined in the metadata. |
|
NonFlushedChanges |
getNonFlushedChanges()
Return changes to this session and its child sessions that have not been flushed yet. |
|
PersistenceContext |
getPersistenceContext()
Get the persistence context for this session |
|
SessionFactoryImplementor |
getSessionFactory()
Get the session factory which created this session. |
|
SessionStatistics |
getStatistics()
Get the statistics for this session. |
|
long |
getTimestamp()
System time before the start of the transaction |
|
Transaction |
getTransaction()
Get the Transaction instance associated with this session. |
|
TransactionCoordinator |
getTransactionCoordinator()
Retrieve access to the session's transaction coordinator. |
|
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) |
|
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()
Should session automatically be closed after transaction completion in this context? |
|
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()
Should before transaction completion processing perform a flush when initiated from JTA synchronization for this context? |
|
boolean |
isFlushModeNever()
Should flushes only happen manually for this context? |
|
boolean |
isOpen()
Check if the session is still open. |
|
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 |
|
List |
list(CriteriaImpl 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 |
|
Object |
load(Class entityClass,
Serializable id)
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists. |
|
Object |
load(Class 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. |
|
Object |
load(Class 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(String entityName,
Object object,
LockMode lockMode)
Obtain the specified lock level upon the given object. |
|
void |
managedClose()
Perform a managed close. |
|
void |
managedFlush()
Perform a managed flush. |
|
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 |
|
String |
onPrepareStatement(String sql)
|
|
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 object,
LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with the given LockMode. |
|
void |
refresh(Object object,
Map refreshedAlready)
Cascade refresh an entity instance |
|
void |
refresh(String entityName,
Object object)
Re-read the state of the given instance from the underlying database. |
|
void |
refresh(String entityName,
Object object,
LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with the given LockMode. |
|
void |
replicate(Object 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). |
|
ScrollableResults |
scroll(CriteriaImpl criteria,
ScrollMode scrollMode)
Execute a criteria query |
|
ScrollableResults |
scroll(String query,
QueryParameters queryParameters)
Execute a scroll() query |
|
ScrollableResults |
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 cacheMode)
Set the cache mode. |
|
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 |
setFetchProfile(String fetchProfile)
Set the current internal fetch profile for this session. |
|
void |
setFlushMode(FlushMode flushMode)
Set the flush mode for this session. |
|
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()
Should JTA synchronization processing perform a automatic close (call to TransactionContext.managedClose() for this
context? |
|
boolean |
shouldAutoJoinTransaction()
Should transactions be auto joined? Generally this is only a concern for CMT transactions. |
|
String |
toString()
|
|
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. |
Methods inherited from class org.hibernate.internal.AbstractSessionImpl |
---|
errorIfClosed, execute, generateCacheKey, generateEntityKey, getFactory, getHQLQueryPlan, getJdbcConnectionAccess, getNamedSQLQuery, getNativeSQLQueryPlan, getTenantIdentifier, getTransactionEnvironment, isClosed, list, scroll, setClosed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.hibernate.engine.spi.SessionImplementor |
---|
generateCacheKey, generateEntityKey, getFactory, getJdbcConnectionAccess, getNamedSQLQuery, getTenantIdentifier, isClosed, list, scroll |
Methods inherited from interface org.hibernate.engine.jdbc.LobCreationContext |
---|
execute |
Methods inherited from interface org.hibernate.SharedSessionContract |
---|
getTenantIdentifier |
Method Detail |
---|
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 Session
public long getTimestamp()
SessionImplementor
getTimestamp
in interface SessionImplementor
public Connection close() throws HibernateException
Session
Session.disconnect()
it.
close
in interface Session
HibernateException
- Indicates problems cleaning up.public ConnectionReleaseMode getConnectionReleaseMode()
TransactionContext
getConnectionReleaseMode
in interface TransactionContext
public boolean shouldAutoJoinTransaction()
TransactionContext
shouldAutoJoinTransaction
in interface TransactionContext
public boolean isAutoCloseSessionEnabled()
TransactionContext
isAutoCloseSessionEnabled
in interface TransactionContext
public boolean isOpen()
Session
isOpen
in interface SessionImplementor
isOpen
in interface Session
public boolean isFlushModeNever()
TransactionContext
isFlushModeNever
in interface TransactionContext
public boolean isFlushBeforeCompletionEnabled()
TransactionContext
isFlushBeforeCompletionEnabled
in interface TransactionContext
public void managedFlush()
TransactionContext
managedFlush
in interface TransactionContext
public NonFlushedChanges getNonFlushedChanges() throws HibernateException
getNonFlushedChanges
in interface SessionImplementor
HibernateException
public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) throws HibernateException
applyNonFlushedChanges
in interface SessionImplementor
nonFlushedChanges
- the non-flushed changes
HibernateException
public boolean shouldAutoClose()
TransactionContext
TransactionContext.managedClose()
for this
context?
shouldAutoClose
in interface TransactionContext
public void managedClose()
TransactionContext
managedClose
in interface TransactionContext
public Connection connection() throws HibernateException
connection
in interface SessionImplementor
HibernateException
public boolean isConnected()
Session
isConnected
in interface SessionImplementor
isConnected
in interface Session
public boolean isTransactionInProgress()
SessionImplementor
isTransactionInProgress
in interface SessionImplementor
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 connection
HibernateException
Session.disconnect()
public void setAutoClear(boolean enabled)
SessionImplementor
setAutoClear
in interface SessionImplementor
public void disableTransactionAutoJoin()
SessionImplementor
Synchronization
).
JPA however defines an explicit join transaction operation.
See javax.persistence.EntityManager#joinTransaction
disableTransactionAutoJoin
in interface SessionImplementor
public void afterOperation(boolean success)
success
- Was the operation a successpublic void afterTransactionBegin(TransactionImplementor hibernateTransaction)
afterTransactionBegin
in interface TransactionContext
public void beforeTransactionCompletion(TransactionImplementor hibernateTransaction)
beforeTransactionCompletion
in interface TransactionContext
public void afterTransactionCompletion(TransactionImplementor hibernateTransaction, boolean successful)
afterTransactionCompletion
in interface TransactionContext
public String onPrepareStatement(String sql)
onPrepareStatement
in interface TransactionContext
public LockMode getCurrentLockMode(Object object) throws HibernateException
Session
getCurrentLockMode
in interface Session
object
- a persistent instance
HibernateException
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
SessionImplementor
getEntityUsingInterceptor
in interface SessionImplementor
HibernateException
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 state
HibernateException
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 state
HibernateException
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 class
HibernateException
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 class
HibernateException
public void update(Object obj) throws HibernateException
Session
cascade="save-update"
update
in interface Session
obj
- a detached instance containing updated state
HibernateException
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 state
HibernateException
public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException
Session
lock
in interface Session
object
- a persistent or transient instancelockMode
- the lock level
HibernateException
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 level
public void lock(Object object, LockMode lockMode) throws HibernateException
Session
lock
in interface Session
object
- a persistent or transient instancelockMode
- the lock level
HibernateException
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 persistent
HibernateException
public void persist(Object object) throws HibernateException
Session
cascade="persist"
The semantics of this method are defined by JSR-220.
persist
in interface Session
object
- a transient instance to be made persistent
HibernateException
public void persist(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSource
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 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 copied
HibernateException
public Object merge(Object object) throws HibernateException
Session
cascade="merge"
The semantics of this method are defined by JSR-220.
merge
in interface Session
object
- a detached instance with state to be copied
HibernateException
public void merge(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSource
merge
in interface EventSource
HibernateException
public void delete(Object object) throws HibernateException
delete
in interface Session
object
- the instance to be removed
HibernateException
public void delete(String entityName, Object object) throws HibernateException
delete
in interface Session
entityName
- The entity name for the instance to be removed.object
- the instance to be removed
HibernateException
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities) throws HibernateException
delete
in interface EventSource
HibernateException
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 class
HibernateException
public Object load(Class entityClass, Serializable id) throws HibernateException
Session
load
in interface Session
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the class
HibernateException
public Object load(String entityName, Serializable id) throws HibernateException
Session
load
in interface Session
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the class
HibernateException
public Object get(Class entityClass, Serializable id) throws HibernateException
Session
get
in interface Session
entityClass
- a persistent classid
- an identifier
HibernateException
public Object get(String entityName, Serializable id) throws HibernateException
Session
get
in interface Session
entityName
- the entity nameid
- an identifier
HibernateException
public Object immediateLoad(String entityName, Serializable id) throws HibernateException
immediateLoad
in interface SessionImplementor
HibernateException
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException
SessionImplementor
internalLoad
in interface SessionImplementor
HibernateException
public Object load(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException
Session
load
in interface Session
entityClass
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock level
HibernateException
public Object load(Class 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 level
HibernateException
public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException
Session
load
in interface Session
entityName
- a persistent classid
- a valid identifier of an existing persistent instance of the classlockMode
- the lock level
HibernateException
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 level
HibernateException
public Object get(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException
Session
get
in interface Session
entityClass
- a persistent classid
- an identifierlockMode
- the lock mode
HibernateException
public Object get(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException
Session
get
in interface Session
entityClass
- a persistent classid
- an identifierlockOptions
- the lock mode
HibernateException
public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException
Session
get
in interface Session
entityName
- the entity nameid
- an identifierlockMode
- the lock mode
HibernateException
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 mode
HibernateException
public org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl byId(String entityName)
Session
IdentifierLoadAccess
instance to retrieve the specified entity type by
primary key.
byId
in interface Session
entityName
- The entity name of the entity type to be retrieved
public org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl byId(Class entityClass)
Session
IdentifierLoadAccess
instance to retrieve the specified entity by
primary key.
byId
in interface Session
entityClass
- The entity type to be retrieved
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 retrieved
public NaturalIdLoadAccess byNaturalId(Class entityClass)
Session
NaturalIdLoadAccess
instance to retrieve the specified entity by
its natural id.
byNaturalId
in interface Session
entityClass
- The entity type to be retrieved
public 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 retrieved
public SimpleNaturalIdLoadAccess bySimpleNaturalId(Class 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 retrieved
public void refresh(Object object) throws HibernateException
Session
refresh
in interface Session
object
- a persistent or detached instance
HibernateException
public void refresh(String entityName, Object object) throws HibernateException
Session
refresh
in interface Session
entityName
- a persistent classobject
- a persistent or detached instance
HibernateException
public void refresh(Object object, LockMode lockMode) throws HibernateException
Session
refresh
in interface Session
object
- a persistent or detached instancelockMode
- the lock mode to use
HibernateException
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 use
HibernateException
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 use
HibernateException
public void refresh(Object object, Map refreshedAlready) throws HibernateException
EventSource
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 use
HibernateException
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 use
HibernateException
public void evict(Object object) throws HibernateException
evict
in interface Session
object
- a persistent instance
HibernateException
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)
,
Transaction.commit()
calls this method).
Flushing is the process of synchronizing the underlying persistent
store with persistable state held in memory.
flush
in interface SessionImplementor
flush
in interface Session
HibernateException
- Indicates problems flushing the session or
talking to the database.public void forceFlush(EntityEntry entityEntry) throws HibernateException
EventSource
forceFlush
in interface EventSource
HibernateException
public List list(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementor
list
in interface SessionImplementor
HibernateException
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementor
executeUpdate
in interface SessionImplementor
HibernateException
public int executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification, QueryParameters queryParameters) throws HibernateException
SessionImplementor
executeNativeUpdate
in interface SessionImplementor
HibernateException
public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementor
iterate
in interface SessionImplementor
HibernateException
public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementor
scroll
in interface SessionImplementor
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 Query getNamedQuery(String queryName) throws MappingException
SharedSessionContract
Query
instance for the named query string defined in the metadata.
getNamedQuery
in interface SessionImplementor
getNamedQuery
in interface SharedSessionContract
getNamedQuery
in class AbstractSessionImpl
queryName
- the name of a query defined externally
MappingException
public Object instantiate(String entityName, Serializable id) throws HibernateException
SessionImplementor
instantiate
in interface SessionImplementor
HibernateException
public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException
instantiate
in interface EventSource
HibernateException
public void setFlushMode(FlushMode flushMode)
Session
FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).
setFlushMode
in interface SessionImplementor
setFlushMode
in interface Session
flushMode
- the new flush modeFlushMode
public FlushMode getFlushMode()
Session
getFlushMode
in interface SessionImplementor
getFlushMode
in interface Session
public CacheMode getCacheMode()
Session
getCacheMode
in interface SessionImplementor
getCacheMode
in interface Session
public void setCacheMode(CacheMode cacheMode)
Session
setCacheMode
in interface SessionImplementor
setCacheMode
in interface Session
cacheMode
- The new cache mode.public Transaction getTransaction() throws HibernateException
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 SharedSessionContract
HibernateException
public Transaction beginTransaction() throws HibernateException
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
HibernateException
SharedSessionContract.getTransaction()
public EntityPersister getEntityPersister(String entityName, Object object)
SessionImplementor
getEntityPersister
in interface SessionImplementor
entityName
- optional entity nameobject
- the entity instancepublic Serializable getIdentifier(Object object) throws HibernateException
Session
getIdentifier
in interface Session
object
- a persistent instance
TransientObjectException
- if the instance is transient or associated with
a different session
HibernateException
public Serializable getContextEntityIdentifier(Object object)
getContextEntityIdentifier
in interface SessionImplementor
public List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
SessionImplementor
listFilter
in interface SessionImplementor
HibernateException
public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
SessionImplementor
iterateFilter
in interface SessionImplementor
HibernateException
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 use
public 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 use
public 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/implementors
public Criteria createCriteria(String entityName)
SharedSessionContract
Criteria
instance for the given entity name.
createCriteria
in interface SharedSessionContract
entityName
- The entity name
public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode)
SessionImplementor
scroll
in interface SessionImplementor
public List list(CriteriaImpl criteria) throws HibernateException
SessionImplementor
list
in interface SessionImplementor
HibernateException
public boolean contains(Object object)
Session
contains
in interface Session
object
- an instance of a persistent class
public Query createQuery(String queryString)
SharedSessionContract
Query
instance for the given HQL query string.
createQuery
in interface SharedSessionContract
createQuery
in class AbstractSessionImpl
queryString
- The HQL query
public SQLQuery createSQLQuery(String sql)
SharedSessionContract
SQLQuery
instance for the given SQL query string.
createSQLQuery
in interface SharedSessionContract
createSQLQuery
in class AbstractSessionImpl
sql
- The SQL query
public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
SessionImplementor
scrollCustomQuery
in interface SessionImplementor
HibernateException
public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
SessionImplementor
listCustomQuery
in interface SessionImplementor
HibernateException
public SessionFactoryImplementor getSessionFactory()
Session
getSessionFactory
in interface Session
SessionFactory
public void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException
SessionImplementor
initializeCollection
in interface SessionImplementor
HibernateException
public String bestGuessEntityName(Object object)
SessionImplementor
bestGuessEntityName
in interface SessionImplementor
public String getEntityName(Object object)
Session
getEntityName
in interface Session
object
- a persistent entity
public String guessEntityName(Object object) throws HibernateException
SessionImplementor
guessEntityName
in interface SessionImplementor
HibernateException
public void cancelQuery() throws HibernateException
Session
cancelQuery
in interface Session
HibernateException
- There was a problem canceling the querypublic Interceptor getInterceptor()
SessionImplementor
getInterceptor
in interface SessionImplementor
public int getDontFlushFromFind()
getDontFlushFromFind
in interface SessionImplementor
public String toString()
toString
in class Object
public ActionQueue getActionQueue()
EventSource
getActionQueue
in interface EventSource
public PersistenceContext getPersistenceContext()
SessionImplementor
getPersistenceContext
in interface SessionImplementor
public SessionStatistics getStatistics()
Session
getStatistics
in interface Session
public boolean isEventSource()
isEventSource
in interface SessionImplementor
public boolean isDefaultReadOnly()
isDefaultReadOnly
in interface Session
Session.isReadOnly(Object)
public void setDefaultReadOnly(boolean defaultReadOnly)
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 HibernateProxy
true
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
work
- The work to be performed.
ReturningWork.execute(java.sql.Connection)
.
HibernateException
- Generally indicates wrapped SQLException
public void afterScrollOperation()
afterScrollOperation
in interface SessionImplementor
public TransactionCoordinator getTransactionCoordinator()
SessionImplementor
getTransactionCoordinator
in interface SessionImplementor
public LoadQueryInfluencers getLoadQueryInfluencers()
SessionImplementor
getLoadQueryInfluencers
in interface SessionImplementor
public Filter getEnabledFilter(String filterName)
getEnabledFilter
in interface Session
filterName
- The name of the filter to be retrieved.
public Filter enableFilter(String filterName)
enableFilter
in interface Session
filterName
- The name of the filter to be enabled.
public void disableFilter(String filterName)
disableFilter
in interface Session
filterName
- The name of the filter to be disabled.public Object getFilterParameterValue(String filterParameterName)
getFilterParameterValue
in interface SessionImplementor
filterParameterName
- The filter parameter name in the format
{FILTER_NAME.PARAMETER_NAME}.
public Type getFilterParameterType(String filterParameterName)
getFilterParameterType
in interface SessionImplementor
filterParameterName
- The filter parameter name in the format
{FILTER_NAME.PARAMETER_NAME}.
public Map getEnabledFilters()
FilterImpl
instance.
getEnabledFilters
in interface SessionImplementor
public String getFetchProfile()
getFetchProfile
in interface SessionImplementor
public void setFetchProfile(String fetchProfile)
setFetchProfile
in interface SessionImplementor
fetchProfile
- The internal fetch profile name to usepublic 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()
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |