Package org.hibernate.engine
Interface SessionImplementor
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
EventSource
- All Known Implementing Classes:
AbstractSessionImpl,SessionImpl,StatelessSessionImpl
Defines the internal contract between the Session and other parts of
Hibernate such as implementors of Type or EntityPersister.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidafterTransactionCompletion(boolean successful, Transaction tx) Notify the session that the transaction completed, so we no longer own the old locks.voidapplyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) Apply non-flushed changes from a different session to this session.voidNotify the session that the transaction is about to completebestGuessEntityName(Object object) The best guess entity name for an entity not in an associationintexecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) Execute a native SQL update or delete queryintexecuteUpdate(String query, QueryParameters queryParameters) Execute a HQL update or delete queryvoidflush()Get the prepared statement Batcher for this sessiongetContextEntityIdentifier(Object object) Return the identifier of the persistent object, or null if not associated with the sessionintDeprecated.use #getLoadQueryInfluencers insteadgetEntityPersister(String entityName, Object object) Get the EntityPersister for any instanceGet the entity instance associated with the given Key, calling the Interceptor if necessaryGet the creating SessionFactoryImplementorDeprecated.use #getLoadQueryInfluencers insteadgetFilterParameterType(String filterParameterName) Deprecated.use #getLoadQueryInfluencers insteadgetFilterParameterValue(String filterParameterName) Deprecated.use #getLoadQueryInfluencers insteadRetrieves the interceptor currently in use by this event source.Retrieves the configured event listeners from this event source.Get the load query influencers associated with this session.getNamedQuery(String name) Get a Query instance for a named query or named native SQL querygetNamedSQLQuery(String name) Get a Query instance for a named native SQL queryReturn changes to this session that have not been flushed yet.Get the persistence context for this sessionlongSystem time before the start of the transactionguessEntityName(Object entity) The guessed entity name for an entity not in an associationimmediateLoad(String entityName, Serializable id) Load an instance immediately.voidinitializeCollection(PersistentCollection collection, boolean writing) Initialize the collection (if not already initialized)instantiate(String entityName, Serializable id) Instantiate the entity class, initializing with the given identifierinternalLoad(String entityName, Serializable id, boolean eager, boolean nullable) Load an instance without checking if it was deleted.booleanisClosed()Determine whether the session is closed.booleanbooleanbooleanisOpen()booleanDoes this Session have an active Hibernate transaction or is there a JTA transaction in progress?iterate(String query, QueryParameters queryParameters) Execute an iterate() queryiterateFilter(Object collection, String filter, QueryParameters queryParameters) Iterate a filterlist(String query, QueryParameters queryParameters) Execute a find() querylist(NativeSQLQuerySpecification spec, QueryParameters queryParameters) Execute a native SQL query, and return the results as a fully built list.list(CriteriaImpl criteria) Execute a criteria querylistCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) Execute an SQL QuerylistFilter(Object collection, String filter, QueryParameters queryParameters) Execute a filterscroll(String query, QueryParameters queryParameters) Execute a scroll() queryscroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters) Execute a native SQL query, and return the results as a scrollable result.scroll(CriteriaImpl criteria, ScrollMode scrollMode) Execute a criteria queryscrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) Execute an SQL QueryvoidsetAutoClear(boolean enabled) Enable/disable automatic cache clearing from after transaction completion (for EJB3)voidvoidsetFetchProfile(String name) Deprecated.use #getLoadQueryInfluencers insteadvoid
-
Method Details
-
getInterceptor
Interceptor getInterceptor()Retrieves the interceptor currently in use by this event source.- Returns:
- The interceptor.
-
setAutoClear
void setAutoClear(boolean enabled) Enable/disable automatic cache clearing from after transaction completion (for EJB3) -
isTransactionInProgress
boolean isTransactionInProgress()Does this Session have an active Hibernate transaction or is there a JTA transaction in progress? -
initializeCollection
void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException Initialize the collection (if not already initialized)- Throws:
HibernateException
-
internalLoad
Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException Load an instance without checking if it was deleted. When nullable is disabled this method may create a new proxy or return an existing proxy; if it does not exist, throw an exception. When nullable is enabled, the method does not create new proxies (but might return an existing proxy); if it does not exist, return null. When eager is enabled, the object is eagerly fetched- Throws:
HibernateException
-
immediateLoad
Load an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Throws:
HibernateException
-
getTimestamp
long getTimestamp()System time before the start of the transaction -
getFactory
SessionFactoryImplementor getFactory()Get the creating SessionFactoryImplementor -
getBatcher
Batcher getBatcher()Get the prepared statement Batcher for this session -
list
Execute a find() query- Throws:
HibernateException
-
iterate
Execute an iterate() query- Throws:
HibernateException
-
scroll
Execute a scroll() query- Throws:
HibernateException
-
scroll
Execute a criteria query -
list
Execute a criteria query -
listFilter
List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException Execute a filter- Throws:
HibernateException
-
iterateFilter
Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException Iterate a filter- Throws:
HibernateException
-
getEntityPersister
Get the EntityPersister for any instance- Parameters:
entityName- optional entity nameobject- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
Get the entity instance associated with the given Key, calling the Interceptor if necessary- Throws:
HibernateException
-
afterTransactionCompletion
Notify the session that the transaction completed, so we no longer own the old locks. (Also we should release cache softlocks.) May be called multiple times during the transaction completion process. Also called after an autocommit, in which case the second argument is null. -
beforeTransactionCompletion
Notify the session that the transaction is about to complete -
getContextEntityIdentifier
Return the identifier of the persistent object, or null if not associated with the session -
bestGuessEntityName
The best guess entity name for an entity not in an association -
guessEntityName
The guessed entity name for an entity not in an association- Throws:
HibernateException
-
instantiate
Instantiate the entity class, initializing with the given identifier- Throws:
HibernateException
-
listCustomQuery
List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException Execute an SQL Query- Throws:
HibernateException
-
scrollCustomQuery
ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException Execute an SQL Query- Throws:
HibernateException
-
list
List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException Execute a native SQL query, and return the results as a fully built list.- Parameters:
spec- The specification of the native SQL query to execute.queryParameters- The parameters by which to perform the execution.- Returns:
- The result list.
- Throws:
HibernateException
-
scroll
ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException Execute a native SQL query, and return the results as a scrollable result.- Parameters:
spec- The specification of the native SQL query to execute.queryParameters- The parameters by which to perform the execution.- Returns:
- The resulting scrollable result.
- Throws:
HibernateException
-
getFilterParameterValue
Deprecated.use #getLoadQueryInfluencers insteadRetreive the currently set value for a filter parameter.- Parameters:
filterParameterName- The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.- Returns:
- The filter parameter value.
-
getFilterParameterType
Deprecated.use #getLoadQueryInfluencers insteadRetreive the type for a given filter parrameter.- Parameters:
filterParameterName- The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.- Returns:
- The filter param type
-
getEnabledFilters
Map getEnabledFilters()Deprecated.use #getLoadQueryInfluencers insteadReturn the currently enabled filters. The filter map is keyed by filter name, with values corresponding to theFilterImplinstance.- Returns:
- The currently enabled filters.
-
getDontFlushFromFind
int getDontFlushFromFind() -
getListeners
EventListeners getListeners()Retrieves the configured event listeners from this event source.- Returns:
- The configured event listeners.
-
getPersistenceContext
PersistenceContext getPersistenceContext()Get the persistence context for this session -
executeUpdate
Execute a HQL update or delete query- Throws:
HibernateException
-
executeNativeUpdate
int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException Execute a native SQL update or delete query- Throws:
HibernateException
-
getNonFlushedChanges
Return changes to this session that have not been flushed yet.- Returns:
- The non-flushed changes.
- Throws:
HibernateException
-
applyNonFlushedChanges
Apply non-flushed changes from a different session to this session. It is assumed that this SessionImpl is "clean" (e.g., has no non-flushed changes, no cached entities, no cached collections, no queued actions). The specified NonFlushedChanges object cannot be bound to any session.- Parameters:
nonFlushedChanges- the non-flushed changes- Throws:
HibernateException
-
getEntityMode
EntityMode getEntityMode() -
getCacheMode
CacheMode getCacheMode() -
setCacheMode
-
isOpen
boolean isOpen() -
isConnected
boolean isConnected() -
getFlushMode
FlushMode getFlushMode() -
setFlushMode
-
connection
Connection connection() -
flush
void flush() -
getNamedQuery
Get a Query instance for a named query or named native SQL query -
getNamedSQLQuery
Get a Query instance for a named native SQL query -
isEventSource
boolean isEventSource() -
afterScrollOperation
void afterScrollOperation() -
getFetchProfile
String getFetchProfile()Deprecated.use #getLoadQueryInfluencers insteadGet the internal fetch profile currently associated with this session.- Returns:
- The current internal fetch profile, or null if none currently associated.
-
setFetchProfile
Deprecated.use #getLoadQueryInfluencers insteadSet the current internal fetch profile for this session.- Parameters:
name- The internal fetch profile name to use
-
getJDBCContext
JDBCContext getJDBCContext() -
isClosed
boolean isClosed()Determine whether the session is closed. Provided seperately fromisOpen()as this method does not attempt any JTA synch registration, where asisOpen()does; which makes this one nicer to use for most internal purposes.- Returns:
- True if the session is closed; false otherwise.
-
getLoadQueryInfluencers
LoadQueryInfluencers getLoadQueryInfluencers()Get the load query influencers associated with this session.- Returns:
- the load query influencers associated with this session; should never be null.
-