public interface SharedSessionContractImplementor extends SharedSessionContract, JdbcSessionOwner, TransactionCoordinatorBuilder.Options, LobCreationContext, WrapperOptions, QueryProducerImplementor
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:JdbcSessionOwner
to drive the behavior of a "JDBC session".
Can therefor be used to construct a JdbcCoordinator, which (for now) models a "JDBC session"
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)
LobCreationContext
to act as the context for JDBC LOB instance creation
WrapperOptions
to fulfill the behavior needed while
binding/extracting values to/from JDBC as part of the Type contracts
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:
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)
|
default void |
checkTransactionNeededForUpdateOperation(String exceptionMessage)
Check if an active Transaction is necessary for the update operation to be executed.
|
Connection |
connection() |
<T> QueryImplementor<T> |
createQuery(String jpaqlString,
Class<T> resultClass,
Selection selection,
HibernateEntityManagerImplementor.QueryOptions queryOptions)
Deprecated.
(since 5.2) - see deprecation note on
org.hibernate.jpa.spi.HibernateEntityManagerImplementor#createQuery(java.lang.String, java.lang.Class, javax.persistence.criteria.Selection, org.hibernate.jpa.spi.HibernateEntityManagerImplementor.QueryOptions)
|
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 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()
The converter associated to a Session might be lazily initialized: only invoke
this getter when there is actual need to use it.
|
SessionFactoryImplementor |
getFactory()
Get the creating SessionFactoryImplementor
|
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.
|
PersistenceContext |
getPersistenceContextInternal()
This is similar to
getPersistenceContext() , with
two main differences:
a) this version performs better as
it allows for inlining and probably better prediction
b) see SessionImplgetPersistenceContext() : it
does some checks on the current state of the 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
getTransactionStartTimestamp() instead. |
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(EntityPersister persister,
Serializable id)
Instantiate the entity class of an EntityPersister, initializing with the given identifier.
|
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.
|
default boolean |
isEnforcingFetchGraph() |
boolean |
isEventSource() |
default boolean |
isOpenOrWaitingForAutoClose()
Checks whether the session is open or is waiting for auto-close
|
default boolean |
isQueryParametersValidationEnabled() |
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(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
|
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 scroll() 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) |
default void |
setEnforcingFetchGraph(boolean enforcingFetchGraph) |
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, createQuery, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, doReturningWork, doWork, getJdbcBatchSize, getNamedProcedureCall, getNamedQuery, 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
createQuery, createQuery, createQuery
SessionFactoryImplementor getFactory()
getFactory
in interface QueryProducerImplementor
SessionEventListenerManager getEventListenerManager()
PersistenceContext getPersistenceContext()
getPersistenceContextInternal()
for
an alternative.
This method is not extremely fast: if you need to access
the PersistenceContext multiple times, prefer keeping
a reference to it over invoking this method multiple times.JdbcCoordinator getJdbcCoordinator()
JdbcServices getJdbcServices()
String getTenantIdentifier()
getTenantIdentifier
in interface SharedSessionContract
null
UUID getSessionIdentifier()
boolean isClosed()
SharedSessionContract.isOpen()
as this method does not attempt any JTA synchronization
registration, whereas 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()
true
if the session is closed or if it's waiting for auto-close; false
otherwise.default void checkOpen()
void checkOpen(boolean markForRollbackIfClosed)
markForRollbackIfClosed
is true, marks current transaction (if one) for rollback onlyvoid markForRollbackOnly()
long getTransactionStartTimestamp()
CacheTransactionSynchronization.getCurrentTransactionStartTimestamp()
@Deprecated default long getTimestamp()
getTransactionStartTimestamp()
instead.CacheTransactionSynchronization getCacheTransactionSynchronization()
null
when the Session is not currently part of a transaction.boolean isTransactionInProgress()
default void checkTransactionNeededForUpdateOperation(String exceptionMessage)
exceptionMessage
- the message to use for the TransactionRequiredExceptionTransaction accessTransaction()
EntityKey generateEntityKey(Serializable id, EntityPersister persister)
id
- The entity idpersister
- The entity persisterInterceptor getInterceptor()
void setAutoClear(boolean enabled)
void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException
HibernateException
Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException
HibernateException
Object immediateLoad(String entityName, Serializable id) throws HibernateException
HibernateException
List list(String query, QueryParameters queryParameters) throws HibernateException
HibernateException
Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException
HibernateException
ScrollableResultsImplementor scroll(String query, QueryParameters queryParameters) throws HibernateException
HibernateException
ScrollableResultsImplementor scroll(Criteria criteria, ScrollMode scrollMode)
List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
HibernateException
Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
HibernateException
EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException
entityName
- optional entity nameobject
- the entity instanceHibernateException
Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
HibernateException
Serializable getContextEntityIdentifier(Object object)
String bestGuessEntityName(Object object)
String guessEntityName(Object entity) throws HibernateException
HibernateException
Object instantiate(String entityName, Serializable id) throws HibernateException
HibernateException
Object instantiate(EntityPersister persister, Serializable id) throws HibernateException
instantiate(String, Serializable)
but not always
interchangeable: a single persister might be responsible for multiple types.HibernateException
List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
HibernateException
ScrollableResultsImplementor scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
HibernateException
List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException
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)
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
HibernateException
int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException
HibernateException
CacheMode getCacheMode()
getCacheMode
in interface QueryProducerImplementor
void setCacheMode(CacheMode cm)
@Deprecated void setFlushMode(FlushMode flushMode)
setHibernateFlushMode(FlushMode)
insteadFlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).flushMode
- the new flush modeFlushModeType getFlushMode()
FlushModeType
rather than Hibernate's FlushMode
. For
the former behavior, use getHibernateFlushMode()
instead.void setHibernateFlushMode(FlushMode flushMode)
FlushMode.MANUAL
at the start of the session (in
order to achieve some extra performance).flushMode
- the new flush modeFlushMode getHibernateFlushMode()
getHibernateFlushMode
in interface QueryProducerImplementor
Connection connection()
void flush()
boolean isEventSource()
void afterScrollOperation()
boolean shouldAutoClose()
boolean isAutoCloseSessionEnabled()
default boolean isQueryParametersValidationEnabled()
LoadQueryInfluencers getLoadQueryInfluencers()
ExceptionConverter getExceptionConverter()
default Integer getConfiguredJdbcBatchSize()
SessionFactoryOptions.getJdbcBatchSize()
,
SessionFactoryBuilder.applyJdbcBatchSize(int)
@Deprecated <T> QueryImplementor<T> createQuery(String jpaqlString, Class<T> resultClass, Selection selection, HibernateEntityManagerImplementor.QueryOptions queryOptions)
PersistenceContext getPersistenceContextInternal()
getPersistenceContext()
, with
two main differences:
a) this version performs better as
it allows for inlining and probably better prediction
b) see SessionImplgetPersistenceContext()
: it
does some checks on the current state of the Session.
Choose wisely: performance is important, correctness comes first.default boolean isEnforcingFetchGraph()
default void setEnforcingFetchGraph(boolean enforcingFetchGraph)
Copyright © 2001-2021 Red Hat, Inc. All Rights Reserved.