public abstract class AbstractSharedSessionContract extends Object implements SharedSessionContractImplementor
getEventListenerManager()getJdbcConnectionAccess()getJdbcServices()getTransaction() (and therefore related methods such as beginTransaction(), etc)LobCreationContext.Callback<T>| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected ExceptionConverter |
exceptionConverter |
protected boolean |
waitingForAutoClose |
| Constructor and Description |
|---|
AbstractSharedSessionContract(SessionFactoryImpl factory,
SessionCreationOptions options) |
| 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.
|
protected void |
addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) |
void |
afterTransactionCompletion(boolean successful,
boolean delayed)
An after-completion callback to the owner.
|
protected void |
applyQuerySettingsAndHints(Query query) |
void |
beforeTransactionCompletion()
A before-completion callback to the owner.
|
Transaction |
beginTransaction()
Begin a unit of work and return the associated
Transaction object. |
protected <T> QueryImplementor<T> |
buildQueryFromName(String name,
Class<T> resultType) |
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)
|
protected void |
checkOpenOrWaitingForAutoClose() |
protected void |
checkTransactionSynchStatus() |
protected void |
cleanupOnClose() |
void |
close()
End the session by releasing the JDBC connection and cleaning up.
|
QueryImplementor |
createNamedQuery(String name)
The JPA-defined named query creation method.
|
<R> QueryImplementor<R> |
createNamedQuery(String name,
Class<R> resultClass)
The JPA-defined named, typed query creation method.
|
protected <T> NativeQueryImplementor |
createNativeQuery(NamedSQLQueryDefinition queryDefinition,
Class<T> resultType) |
NativeQueryImplementor |
createNativeQuery(String sqlString)
Create a NativeQuery instance for the given native (SQL) query
|
NativeQueryImplementor |
createNativeQuery(String sqlString,
Class resultClass)
Create a NativeQuery instance for the given native (SQL) query using
implicit mapping to the specified Java type.
|
NativeQueryImplementor |
createNativeQuery(String sqlString,
String resultSetMapping)
Create a NativeQuery instance for the given native (SQL) query using
implicit mapping to the specified Java type.
|
protected QueryImplementor |
createQuery(NamedQueryDefinition queryDefinition) |
protected <T> QueryImplementor<T> |
createQuery(NamedQueryDefinition namedQueryDefinition,
Class<T> resultType) |
QueryImplementor |
createQuery(String queryString)
Create a
Query instance for the given HQL/JPQL query string. |
<T> QueryImplementor<T> |
createQuery(String queryString,
Class<T> resultClass)
Create a typed
Query instance for the given HQL/JPQL query string. |
NativeQueryImplementor |
createSQLQuery(String queryString)
Create a
NativeQuery instance for the given SQL query string. |
ProcedureCall |
createStoredProcedureCall(String procedureName)
Creates a call to a stored procedure.
|
ProcedureCall |
createStoredProcedureCall(String procedureName,
Class... resultClasses)
Creates a call to a stored procedure with specific result set entity mappings.
|
ProcedureCall |
createStoredProcedureCall(String procedureName,
String... resultSetMappings)
Creates a call to a stored procedure with specific result set entity mappings.
|
protected void |
delayedAfterCompletion() |
protected void |
errorIfClosed()
Deprecated.
(since 5.2) use
SharedSessionContractImplementor.checkOpen() instead |
<T> T |
execute(LobCreationContext.Callback<T> callback)
Execute the given callback, making sure it has access to a viable JDBC
Connection. |
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.
|
protected TransactionImplementor |
getCurrentTransaction() |
EntityNameResolver |
getEntityNameResolver() |
SessionEventListenerManager |
getEventListenerManager() |
ExceptionConverter |
getExceptionConverter() |
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.
|
Integer |
getJdbcBatchSize()
Get the Session-level JDBC batch size for the current Session.
|
JdbcConnectionAccess |
getJdbcConnectionAccess() |
JdbcCoordinator |
getJdbcCoordinator() |
JdbcServices |
getJdbcServices() |
JdbcSessionContext |
getJdbcSessionContext() |
TimeZone |
getJdbcTimeZone()
The JDBC
TimeZone used when persisting Timestamp and DateTime properties into the database. |
LobCreator |
getLobCreator()
Obtain access to the
LobCreator |
NativeQueryImplementor |
getNamedNativeQuery(String name)
Get a NativeQuery instance for a named native SQL query
|
ProcedureCall |
getNamedProcedureCall(String name)
Gets a ProcedureCall based on a named template
|
QueryImplementor |
getNamedQuery(String name)
Create a
Query instance for the named query. |
NativeQueryImplementor |
getNamedSQLQuery(String name)
Get a NativeQuery instance for a named native SQL query
|
protected NativeQueryImplementor |
getNativeQueryImplementor(String queryString,
boolean isOrdinalParameterZeroBased) |
protected NativeSQLQueryPlan |
getNativeQueryPlan(NativeSQLQuerySpecification spec) |
protected HQLQueryPlan |
getQueryPlan(String query,
boolean shallow) |
UUID |
getSessionIdentifier()
A UUID associated with each Session.
|
String |
getTenantIdentifier()
The multi-tenancy tenant identifier, if one.
|
Transaction |
getTransaction()
Get the
Transaction instance associated with this session. |
TransactionCoordinator |
getTransactionCoordinator()
Obtain the builder for TransactionCoordinator instances
|
long |
getTransactionStartTimestamp()
A "timestamp" at or before the start of the current transaction.
|
protected void |
initQueryFromNamedDefinition(Query query,
NamedQueryDefinition nqd) |
boolean |
isClosed()
Checks whether the session is closed.
|
boolean |
isConnected()
Check if the session is currently connected.
|
boolean |
isOpen()
Check if the session is still open.
|
boolean |
isOpenOrWaitingForAutoClose()
Checks whether the session is open or is waiting for auto-close
|
boolean |
isTransactionInProgress()
Does this Session have an active Hibernate transaction
or is there a JTA transaction in progress?
|
List |
list(NativeSQLQuerySpecification spec,
QueryParameters queryParameters)
Execute a native SQL query, and return the results as a fully built list.
|
protected abstract Object |
load(String entityName,
Serializable identifier) |
void |
markForRollbackOnly()
Marks current transaction (if one) for rollback only
|
protected void |
pulseTransactionCoordinator() |
SqlTypeDescriptor |
remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
Allow remapping of descriptors for dealing with sql type.
|
protected void |
removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) |
protected void |
resultClassChecking(Class resultType,
NamedSQLQueryDefinition namedQueryDefinition) |
protected void |
resultClassChecking(Class resultClass,
Query hqlQuery) |
ScrollableResultsImplementor |
scroll(NativeSQLQuerySpecification spec,
QueryParameters queryParameters)
Execute a native SQL query, and return the results as a scrollable result.
|
void |
setCacheMode(CacheMode cacheMode) |
protected void |
setClosed() |
void |
setFlushMode(FlushMode flushMode)
Set the flush mode for this session.
|
void |
setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.
|
void |
setJdbcBatchSize(Integer jdbcBatchSize)
Set the Session-level JDBC batch size.
|
boolean |
shouldAutoJoinTransaction()
Indicates whether an active transaction should be automatically joined.
|
protected boolean |
shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) |
void |
startTransactionBoundary()
Callback indicating recognition of entering into a transactional
context whether that is explicitly via the Hibernate
Transaction API or via registration
of Hibernate's JTA Synchronization impl with a JTA Transaction |
boolean |
useStreamForLobBinding()
Should streams be used for binding LOB values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterScrollOperation, bestGuessEntityName, checkOpen, connection, executeNativeUpdate, executeUpdate, flush, getConfiguredJdbcBatchSize, getContextEntityIdentifier, getDontFlushFromFind, getEntityPersister, getEntityUsingInterceptor, getLoadQueryInfluencers, getPersistenceContext, getTimestamp, guessEntityName, immediateLoad, initializeCollection, instantiate, internalLoad, isAutoCloseSessionEnabled, isEventSource, isQueryParametersValidationEnabled, iterate, iterateFilter, list, list, listCustomQuery, listFilter, scroll, scroll, scrollCustomQuery, setAutoClear, shouldAutoClosecreateCriteria, createCriteria, createCriteria, createCriteriaafterTransactionBegin, flushBeforeTransactionCompletionprotected boolean closed
protected boolean waitingForAutoClose
protected transient ExceptionConverter exceptionConverter
public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options)
protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
public boolean shouldAutoJoinTransaction()
TransactionCoordinatorBuilder.OptionsshouldAutoJoinTransaction in interface TransactionCoordinatorBuilder.Optionstrue indicates the active transaction should be auto joined; false
indicates it should not (until TransactionCoordinator.explicitJoin() is called).public SessionFactoryImplementor getFactory()
SharedSessionContractImplementorgetFactory in interface SharedSessionContractImplementorgetFactory in interface QueryProducerImplementorpublic Interceptor getInterceptor()
SharedSessionContractImplementorgetInterceptor in interface SharedSessionContractImplementorpublic JdbcCoordinator getJdbcCoordinator()
getJdbcCoordinator in interface SharedSessionContractImplementorpublic TransactionCoordinator getTransactionCoordinator()
JdbcSessionOwnergetTransactionCoordinator in interface JdbcSessionOwnerpublic JdbcSessionContext getJdbcSessionContext()
getJdbcSessionContext in interface JdbcSessionOwnerpublic EntityNameResolver getEntityNameResolver()
public SessionEventListenerManager getEventListenerManager()
getEventListenerManager in interface SharedSessionContractImplementorpublic UUID getSessionIdentifier()
SharedSessionContractImplementorgetSessionIdentifier in interface SharedSessionContractImplementorpublic String getTenantIdentifier()
SharedSessionContractImplementorgetTenantIdentifier in interface SharedSessionContractImplementorgetTenantIdentifier in interface SharedSessionContractnullpublic boolean isOpen()
SharedSessionContractisOpen in interface SharedSessionContractpublic boolean isClosed()
SharedSessionContractImplementorSharedSessionContract.isOpen() as this method does not attempt any JTA synchronization
registration, where as SharedSessionContract.isOpen() does; which makes this one
nicer to use for most internal purposes.isClosed in interface SharedSessionContractImplementortrue if the session is closed; false otherwise.public void close()
SharedSessionContractclose in interface SharedSessionContractprotected void setClosed()
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
protected void cleanupOnClose()
public boolean isOpenOrWaitingForAutoClose()
SharedSessionContractImplementorisOpenOrWaitingForAutoClose in interface SharedSessionContractImplementortrue if the session is closed or if it's waiting for auto-close; false otherwise.public void checkOpen(boolean markForRollbackIfClosed)
SharedSessionContractImplementormarkForRollbackIfClosed is true, marks current transaction (if one) for rollback onlycheckOpen in interface SharedSessionContractImplementorprotected void checkOpenOrWaitingForAutoClose()
@Deprecated protected void errorIfClosed()
SharedSessionContractImplementor.checkOpen() insteadpublic void markForRollbackOnly()
SharedSessionContractImplementormarkForRollbackOnly in interface SharedSessionContractImplementorpublic boolean isTransactionInProgress()
SharedSessionContractImplementorisTransactionInProgress in interface SharedSessionContractImplementorpublic Transaction getTransaction() throws HibernateException
SharedSessionContractTransaction instance associated with this session. The concrete type of the returned
Transaction object is determined by the hibernate.transaction_factory property.getTransaction in interface SharedSessionContractHibernateExceptionpublic Transaction accessTransaction()
SharedSessionContractImplementoraccessTransaction in interface SharedSessionContractImplementorpublic void startTransactionBoundary()
JdbcSessionOwnerTransaction API or via registration
of Hibernate's JTA Synchronization impl with a JTA TransactionstartTransactionBoundary in interface JdbcSessionOwnerpublic void beforeTransactionCompletion()
JdbcSessionOwnerbeforeTransactionCompletion in interface JdbcSessionOwnerpublic void afterTransactionCompletion(boolean successful,
boolean delayed)
JdbcSessionOwnerafterTransactionCompletion in interface JdbcSessionOwnersuccessful - Was the transaction successful?delayed - Is this a delayed after transaction completion call (aka after a timeout)?public CacheTransactionSynchronization getCacheTransactionSynchronization()
SharedSessionContractImplementornull when the Session is not currently part of a transaction.getCacheTransactionSynchronization in interface SharedSessionContractImplementorpublic long getTransactionStartTimestamp()
SharedSessionContractImplementorgetTransactionStartTimestamp in interface SharedSessionContractImplementorpublic Transaction beginTransaction()
SharedSessionContractTransaction 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 SharedSessionContractSharedSessionContract.getTransaction()protected void checkTransactionSynchStatus()
protected void pulseTransactionCoordinator()
protected void delayedAfterCompletion()
protected TransactionImplementor getCurrentTransaction()
public boolean isConnected()
SharedSessionContractisConnected in interface SharedSessionContractpublic JdbcConnectionAccess getJdbcConnectionAccess()
getJdbcConnectionAccess in interface JdbcSessionOwnerpublic EntityKey generateEntityKey(Serializable id, EntityPersister persister)
SharedSessionContractImplementorgenerateEntityKey in interface SharedSessionContractImplementorid - The entity idpersister - The entity persisterpublic boolean useStreamForLobBinding()
WrapperOptionsuseStreamForLobBinding in interface WrapperOptionstrue/falsepublic LobCreator getLobCreator()
WrapperOptionsLobCreatorgetLobCreator in interface WrapperOptionspublic <T> T execute(LobCreationContext.Callback<T> callback)
LobCreationContextConnection.execute in interface LobCreationContextT - The Java type of the type of LOB being created. One of Blob,
Clob, NClobcallback - The callback to execute .public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
WrapperOptionsremapSqlTypeDescriptor in interface WrapperOptionssqlTypeDescriptor - The known descriptorpublic TimeZone getJdbcTimeZone()
WrapperOptionsTimeZone used when persisting Timestamp and DateTime properties into the database.
This setting is used when storing timestamps using the PreparedStatement.setTimestamp(int, Timestamp, Calendar) method.
This way, the storage TimeZone can differ from the default JVM TimeZone given by TimeZone.getDefault().getJdbcTimeZone in interface WrapperOptionsTimeZonepublic JdbcServices getJdbcServices()
getJdbcServices in interface SharedSessionContractImplementorpublic void setFlushMode(FlushMode flushMode)
SharedSessionContractImplementorFlushMode.MANUAL at the start of the session (in
order to achieve some extra performance).setFlushMode in interface SharedSessionContractImplementorflushMode - the new flush modepublic FlushModeType getFlushMode()
SharedSessionContractImplementorFlushModeType rather than Hibernate's FlushMode. For
the former behavior, use SharedSessionContractImplementor.getHibernateFlushMode() instead.getFlushMode in interface SharedSessionContractImplementorpublic void setHibernateFlushMode(FlushMode flushMode)
SharedSessionContractImplementorFlushMode.MANUAL at the start of the session (in
order to achieve some extra performance).setHibernateFlushMode in interface SharedSessionContractImplementorflushMode - the new flush modepublic FlushMode getHibernateFlushMode()
SharedSessionContractImplementorgetHibernateFlushMode in interface SharedSessionContractImplementorgetHibernateFlushMode in interface QueryProducerImplementorpublic CacheMode getCacheMode()
getCacheMode in interface SharedSessionContractImplementorgetCacheMode in interface QueryProducerImplementorpublic void setCacheMode(CacheMode cacheMode)
setCacheMode in interface SharedSessionContractImplementorprotected HQLQueryPlan getQueryPlan(String query, boolean shallow) throws HibernateException
HibernateExceptionprotected NativeSQLQueryPlan getNativeQueryPlan(NativeSQLQuerySpecification spec) throws HibernateException
HibernateExceptionpublic QueryImplementor getNamedQuery(String name)
QueryProducerQuery instance for the named query.getNamedQuery in interface QueryProducergetNamedQuery in interface QueryProducerImplementorname - the name of a pre-defined, named queryprotected QueryImplementor createQuery(NamedQueryDefinition queryDefinition)
protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition nqd)
public QueryImplementor createQuery(String queryString)
QueryProducerQuery instance for the given HQL/JPQL query string.createQuery in interface QueryProducercreateQuery in interface QueryProducerImplementorqueryString - The HQL/JPQL queryEntityManager.createQuery(String)protected void applyQuerySettingsAndHints(Query query)
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> resultClass)
QueryProducerQuery instance for the given HQL/JPQL query string.createQuery in interface QueryProducercreateQuery in interface QueryProducerImplementorqueryString - The HQL/JPQL queryEntityManager.createQuery(String,Class)public QueryImplementor createNamedQuery(String name)
QueryProducercreateNamedQuery in interface QueryProducercreateNamedQuery in interface QueryProducerImplementorname - the name of a pre-defined, named queryEntityManager.createNamedQuery(String)protected <T> QueryImplementor<T> buildQueryFromName(String name, Class<T> resultType)
protected <T> QueryImplementor<T> createQuery(NamedQueryDefinition namedQueryDefinition, Class<T> resultType)
protected <T> NativeQueryImplementor createNativeQuery(NamedSQLQueryDefinition queryDefinition, Class<T> resultType)
protected void resultClassChecking(Class resultType, NamedSQLQueryDefinition namedQueryDefinition)
public <R> QueryImplementor<R> createNamedQuery(String name, Class<R> resultClass)
QueryProducercreateNamedQuery in interface QueryProducercreateNamedQuery in interface QueryProducerImplementorname - the name of a query defined in metadataresultClass - the type of the query resultEntityManager.createNamedQuery(String,Class)public NativeQueryImplementor createNativeQuery(String sqlString)
QueryProducercreateNativeQuery in interface QueryProducercreateNativeQuery in interface QueryProducerImplementorsqlString - a native SQL query stringEntityManager.createNativeQuery(String)public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass)
QueryProducercreateNativeQuery in interface QueryProducercreateNativeQuery in interface QueryProducerImplementorsqlString - Native (SQL) query stringresultClass - The Java type to map results toEntityManager.createNativeQuery(String,Class)public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMapping)
QueryProducercreateNativeQuery in interface QueryProducercreateNativeQuery in interface QueryProducerImplementorsqlString - Native (SQL) query stringresultSetMapping - The explicit (named) result mappingEntityManager.createNativeQuery(String,Class),
SqlResultSetMappingpublic NativeQueryImplementor getNamedNativeQuery(String name)
QueryProducergetNamedNativeQuery in interface QueryProducergetNamedNativeQuery in interface QueryProducerImplementorname - The name of the pre-defined querypublic NativeQueryImplementor createSQLQuery(String queryString)
QueryProducerNativeQuery instance for the given SQL query string.createSQLQuery in interface QueryProducercreateSQLQuery in interface QueryProducerImplementorqueryString - The SQL queryprotected NativeQueryImplementor getNativeQueryImplementor(String queryString, boolean isOrdinalParameterZeroBased)
public NativeQueryImplementor getNamedSQLQuery(String name)
QueryProducergetNamedSQLQuery in interface QueryProducergetNamedSQLQuery in interface QueryProducerImplementorname - The name of the pre-defined querypublic ProcedureCall getNamedProcedureCall(String name)
SharedSessionContractgetNamedProcedureCall in interface SharedSessionContractname - The name given to the templateNamedStoredProcedureQuerypublic ProcedureCall createStoredProcedureCall(String procedureName)
SharedSessionContractcreateStoredProcedureCall in interface SharedSessionContractprocedureName - The name of the procedure.public ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses)
SharedSessionContractcreateStoredProcedureCall in interface SharedSessionContractprocedureName - The name of the procedure.resultClasses - The entity(s) to map the result on to.public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
SharedSessionContractcreateStoredProcedureCall in interface SharedSessionContractprocedureName - The name of the procedure.resultSetMappings - The explicit result set mapping(s) to use for mapping the resultsprotected abstract Object load(String entityName, Serializable identifier)
public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
SharedSessionContractImplementorlist in interface SharedSessionContractImplementorspec - The specification of the native SQL query to execute.queryParameters - The parameters by which to perform the execution.public ScrollableResultsImplementor scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
SharedSessionContractImplementorscroll in interface SharedSessionContractImplementorspec - The specification of the native SQL query to execute.queryParameters - The parameters by which to perform the execution.public ExceptionConverter getExceptionConverter()
getExceptionConverter in interface SharedSessionContractImplementorpublic Integer getJdbcBatchSize()
SharedSessionContracthibernate.default_batch_fetch_size configuration property for the scope of the current Session.getJdbcBatchSize in interface JdbcSessionOwnergetJdbcBatchSize in interface SharedSessionContractSessionFactoryOptions.getJdbcBatchSize(),
SessionFactoryBuilder.applyJdbcBatchSize(int)public void setJdbcBatchSize(Integer jdbcBatchSize)
SharedSessionContracthibernate.default_batch_fetch_size configuration property for the scope of the current Session.setJdbcBatchSize in interface SharedSessionContractjdbcBatchSize - Session-level JDBC batch sizeSessionFactoryOptions.getJdbcBatchSize(),
SessionFactoryBuilder.applyJdbcBatchSize(int)Copyright © 2019 JBoss by Red Hat. All rights reserved.