public interface SharedSessionContractImplementor extends SharedSessionContract, JdbcSessionOwner, TransactionCoordinatorBuilder.Options, LobCreationContext, WrapperOptions, QueryProducerImplementor
Defines the internal contract shared between Session
and
StatelessSession
as used by other parts of Hibernate (such as
Type
, EntityPersister
and
CollectionPersister
implementors
A Session, through this interface and SharedSessionContractImplementor, implements:<ul>
<li>
JdbcSessionOwner
to drive the behavior of a "JDBC session".
Can therefor be used to construct a JdbcCoordinator, which (for now) models a "JDBC session"
</li>
<li>
TransactionCoordinatorBuilder.Options
to drive the creation of the TransactionCoordinator
delegate.
This allows it to be passed along to
TransactionCoordinatorBuilder.buildTransactionCoordinator(org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner, org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options)
</li>
<li>
LobCreationContext
to act as the context for JDBC LOB instance creation
</li>
<li>
WrapperOptions
to fulfill the behavior needed while
binding/extracting values to/from JDBC as part of the Type contracts
</li>
</ul>
LobCreationContext.Callback<T>
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 |
afterScrollOperation() |
String |
bestGuessEntityName(Object object)
The best guess entity name for an entity not in an association
|
default void |
checkOpen()
Performs a check whether the Session is open, and if not:<ul>
<li>marks current transaction (if one) for rollback only</li>
<li>throws an IllegalStateException (JPA defines the exception type)</li>
</ul>
|
void |
checkOpen(boolean markForRollbackIfClosed)
Performs a check whether the Session is open, and if not:<ul>
<li>if
markForRollbackIfClosed is true, marks current transaction (if one) for rollback only</li>
<li>throws an IllegalStateException (JPA defines the exception type)</li>
</ul> |
Connection |
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
|
void |
flush() |
EntityKey |
generateEntityKey(Serializable id,
EntityPersister persister)
Hide the changing requirements of entity key creation
|
CacheMode |
getCacheMode() |
CacheTransactionSynchronization |
getCacheTransactionSynchronization()
The current CacheTransactionContext associated with the Session.
|
default Integer |
getConfiguredJdbcBatchSize()
Get the currently configured JDBC batch size either at the Session-level or SessionFactory-level.
|
Serializable |
getContextEntityIdentifier(Object object)
Return the identifier of the persistent object, or null if
not associated with the session
|
int |
getDontFlushFromFind() |
EntityPersister |
getEntityPersister(String entityName,
Object object)
Get the <tt>EntityPersister</tt> for any instance
|
Object |
getEntityUsingInterceptor(EntityKey key)
Get the entity instance associated with the given <tt>Key</tt>,
calling the Interceptor if necessary
|
SessionEventListenerManager |
getEventListenerManager() |
ExceptionConverter |
getExceptionConverter() |
SessionFactoryImplementor |
getFactory()
Get the creating <tt>SessionFactoryImplementor</tt>
|
FlushModeType |
getFlushMode()
Get the flush mode for this session.
|
FlushMode |
getHibernateFlushMode()
Get the current flush mode for this session.
|
Interceptor |
getInterceptor()
Retrieves the interceptor currently in use by this event source.
|
JdbcCoordinator |
getJdbcCoordinator() |
JdbcServices |
getJdbcServices() |
LoadQueryInfluencers |
getLoadQueryInfluencers()
Get the load query influencers associated with this session.
|
PersistenceContext |
getPersistenceContext()
Get the persistence context for this session
|
UUID |
getSessionIdentifier()
A UUID associated with each Session.
|
String |
getTenantIdentifier()
The multi-tenancy tenant identifier, if one.
|
default long |
getTimestamp()
Deprecated.
(since 5.3) Use
|
long |
getTransactionStartTimestamp()
A "timestamp" at or before the start of the current transaction.
|
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(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 |
isEventSource() |
default boolean |
isOpenOrWaitingForAutoClose()
Checks whether the session is open or is waiting for auto-close
|
default boolean |
isQueryParametersValidationEnabled() |
boolean |
isTransactionInProgress()
Does this <tt>Session</tt> have an active Hibernate transaction
or is there a JTA transaction in progress?
|
Iterator |
iterate(String query,
QueryParameters queryParameters)
Execute an <tt>iterate()</tt> query
|
Iterator |
iterateFilter(Object collection,
String filter,
QueryParameters queryParameters)
Iterate a filter
|
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 <tt>find()</tt> query
|
List |
listCustomQuery(CustomQuery customQuery,
QueryParameters queryParameters)
Execute an SQL Query
|
List |
listFilter(Object collection,
String filter,
QueryParameters queryParameters)
Execute a filter
|
void |
markForRollbackOnly()
Marks current transaction (if one) for rollback only
|
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 <tt>scroll()</tt> query
|
ScrollableResultsImplementor |
scrollCustomQuery(CustomQuery customQuery,
QueryParameters queryParameters)
Execute an SQL Query
|
void |
setAutoClear(boolean enabled)
Enable/disable automatic cache clearing from after transaction
completion (for EJB3)
|
void |
setCacheMode(CacheMode cm) |
void |
setFlushMode(FlushMode flushMode)
Deprecated.
(since 5.2) use
setHibernateFlushMode(FlushMode) instead |
void |
setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.
|
boolean |
shouldAutoClose() |
beginTransaction, close, createCriteria, createCriteria, createCriteria, createCriteria, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, getJdbcBatchSize, getNamedProcedureCall, getTransaction, isConnected, isOpen, setJdbcBatchSize
afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, flushBeforeTransactionCompletion, getJdbcBatchSize, getJdbcConnectionAccess, getJdbcSessionContext, getTransactionCoordinator, startTransactionBoundary
shouldAutoJoinTransaction
execute
getJdbcTimeZone, getLobCreator, remapSqlTypeDescriptor, useStreamForLobBinding
createNamedQuery, createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, createQuery, createSQLQuery, getNamedNativeQuery, getNamedQuery, getNamedSQLQuery
SessionFactoryImplementor getFactory()
Get the creating <tt>SessionFactoryImplementor</tt>
getFactory
in interface QueryProducerImplementor
SessionEventListenerManager getEventListenerManager()
PersistenceContext getPersistenceContext()
Get the persistence context for this session
JdbcCoordinator getJdbcCoordinator()
JdbcServices getJdbcServices()
String getTenantIdentifier()
The multi-tenancy tenant identifier, if one.
getTenantIdentifier
in interface SharedSessionContract
null
UUID getSessionIdentifier()
A UUID associated with each Session. Useful mainly for logging.
boolean isClosed()
Checks whether the session is closed. Provided separately from
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.
true
if the session is closed; false
otherwise.default boolean isOpenOrWaitingForAutoClose()
Checks whether the session is open or is waiting for auto-close
true
if the session is closed or if it’s waiting for auto-close; false
otherwise.default void checkOpen()
Performs a check whether the Session is open, and if not:<ul> <li>marks current transaction (if one) for rollback only</li> <li>throws an IllegalStateException (JPA defines the exception type)</li> </ul>
void checkOpen(boolean markForRollbackIfClosed)
Performs a check whether the Session is open, and if not:<ul>
<li>if markForRollbackIfClosed
is true, marks current transaction (if one) for rollback only</li>
<li>throws an IllegalStateException (JPA defines the exception type)</li>
</ul>
void markForRollbackOnly()
Marks current transaction (if one) for rollback only
long getTransactionStartTimestamp()
A "timestamp" at or before the start of the current transaction.
@Deprecated default long getTimestamp()
CacheTransactionSynchronization getCacheTransactionSynchronization()
The current CacheTransactionContext associated with the Session. This may
return null
when the Session is not currently part of a transaction.
boolean isTransactionInProgress()
Does this <tt>Session</tt> have an active Hibernate transaction or is there a JTA transaction in progress?
Transaction accessTransaction()
Provides access to the underlying transaction or creates a new transaction if one does not already exist or is active. This is primarily for internal or integrator use.
EntityKey generateEntityKey(Serializable id, EntityPersister persister)
Hide the changing requirements of entity key creation
id
- The entity idpersister
- The entity persisterInterceptor getInterceptor()
Retrieves the interceptor currently in use by this event source.
void setAutoClear(boolean enabled)
Enable/disable automatic cache clearing from after transaction completion (for EJB3)
void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException
Initialize the collection (if not already initialized)
HibernateException
Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException
Load an instance without checking if it was deleted. <p/> When <tt>nullable</tt> is disabled this method may create a new proxy or return an existing proxy; if it does not exist, throw an exception. <p/> When <tt>nullable</tt> is enabled, the method does not create new proxies (but might return an existing proxy); if it does not exist, return <tt>null</tt>. <p/> When <tt>eager</tt> is enabled, the object is eagerly fetched
HibernateException
Object immediateLoad(String entityName, Serializable id) throws HibernateException
Load an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.
HibernateException
List list(String query, QueryParameters queryParameters) throws HibernateException
Execute a <tt>find()</tt> query
HibernateException
Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException
Execute an <tt>iterate()</tt> query
HibernateException
ScrollableResultsImplementor scroll(String query, QueryParameters queryParameters) throws HibernateException
Execute a <tt>scroll()</tt> query
HibernateException
ScrollableResultsImplementor scroll(Criteria criteria, ScrollMode scrollMode)
Execute a criteria query
List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
Execute a filter
HibernateException
Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
Iterate a filter
HibernateException
EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException
Get the <tt>EntityPersister</tt> for any instance
entityName
- optional entity nameobject
- the entity instanceHibernateException
Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
Get the entity instance associated with the given <tt>Key</tt>, calling the Interceptor if necessary
HibernateException
Serializable getContextEntityIdentifier(Object object)
Return the identifier of the persistent object, or null if not associated with the session
String bestGuessEntityName(Object object)
The best guess entity name for an entity not in an association
String guessEntityName(Object entity) throws HibernateException
The guessed entity name for an entity not in an association
HibernateException
Object instantiate(String entityName, Serializable id) throws HibernateException
Instantiate the entity class, initializing with the given identifier
HibernateException
List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
Execute an SQL Query
HibernateException
ScrollableResultsImplementor scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
Execute an SQL Query
HibernateException
List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException
Execute a native SQL query, and return the results as a fully built list.
spec
- The specification of the native SQL query to execute.queryParameters
- The parameters by which to perform the execution.HibernateException
ScrollableResultsImplementor scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
Execute a native SQL query, and return the results as a scrollable result.
spec
- The specification of the native SQL query to execute.queryParameters
- The parameters by which to perform the execution.HibernateException
int getDontFlushFromFind()
int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException
Execute a HQL update or delete query
HibernateException
int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException
Execute a native SQL update or delete query
HibernateException
CacheMode getCacheMode()
getCacheMode
in interface QueryProducerImplementor
void setCacheMode(CacheMode cm)
@Deprecated void setFlushMode(FlushMode flushMode)
setHibernateFlushMode(FlushMode)
insteadSet the flush mode for this session.
<p/>
The flush mode determines the points at which the session is flushed.
<i>Flushing</i> is the process of synchronizing the underlying persistent
store with persistable state held in memory.
<p/>
For a logically "read only" session, it is reasonable to set the session’s
flush mode to FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).
flushMode
- the new flush modeFlushModeType getFlushMode()
Get the flush mode for this session.
<p/>
For users of the Hibernate native APIs, we’ve had to rename this method
as defined by Hibernate historically because the JPA contract defines a method of the same
name, but returning the JPA FlushModeType
rather than Hibernate’s FlushMode
. For
the former behavior, use getHibernateFlushMode()
instead.
void setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.
<p/>
The flush mode determines the points at which the session is flushed.
<i>Flushing</i> is the process of synchronizing the underlying persistent
store with persistable state held in memory.
<p/>
For a logically "read only" session, it is reasonable to set the session’s
flush mode to FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).
flushMode
- the new flush modeFlushMode getHibernateFlushMode()
Get the current flush mode for this session.
getHibernateFlushMode
in interface QueryProducerImplementor
Connection connection()
void flush()
boolean isEventSource()
void afterScrollOperation()
boolean shouldAutoClose()
boolean isAutoCloseSessionEnabled()
default boolean isQueryParametersValidationEnabled()
LoadQueryInfluencers getLoadQueryInfluencers()
Get the load query influencers associated with this session.
ExceptionConverter getExceptionConverter()
default Integer getConfiguredJdbcBatchSize()
Get the currently configured JDBC batch size either at the Session-level or SessionFactory-level.
If the Session-level JDBC batch size was not configured, return the SessionFactory-level one.
SessionFactoryOptions.getJdbcBatchSize()
,
SessionFactoryBuilder.applyJdbcBatchSize(int)
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.