Package net.sf.basedb.core.hibernate
Class SessionWrapper
java.lang.Object
net.sf.basedb.core.hibernate.AbstractQueryCache
net.sf.basedb.core.hibernate.SessionWrapper
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,javax.persistence.EntityManager
,HibernateEntityManager
,QueryProducer
,Session
,SharedSessionContract
Wrapper around Hibernate sessions that includes a query cache.
This wrapper forwards all calls to the underlying real Hibernate
session.
- Since:
- 2.16
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2019-06-17 08:40:32 +0200 (mån, 17 juni 2019) $
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.Session
Session.LockRequest
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListeners
(SessionEventListener... paramArrayOfSessionEventListener) buildLockRequest
(LockOptions options) <T> IdentifierLoadAccess<T>
<T> MultiIdentifierLoadAccess<T>
byMultipleIds
(Class<T> entityClass) byMultipleIds
(String entityName) <T> NaturalIdLoadAccess<T>
byNaturalId
(Class<T> paramClass) byNaturalId
(String paramString) <T> SimpleNaturalIdLoadAccess<T>
bySimpleNaturalId
(Class<T> paramClass) bySimpleNaturalId
(String paramString) void
void
clear()
void
close()
boolean
boolean
createCriteria
(Class persistentClass) Deprecated.createCriteria
(Class persistentClass, String alias) Deprecated.createCriteria
(String entityName) Deprecated.createCriteria
(String entityName, String alias) Deprecated.<T> RootGraph<T>
createEntityGraph
(Class<T> rootType) RootGraph<?>
createEntityGraph
(String graphName) Query<?>
createFilter
(Object collection, String queryString) Deprecated.Query<?>
createNamedQuery
(String queryName) <T> Query<T>
createNamedQuery
(String name, Class<T> resultType) javax.persistence.StoredProcedureQuery
NativeQuery<?>
createNativeQuery
(String sql) createNativeQuery
(String sql, Class resultClass) NativeQuery<?>
createNativeQuery
(String sql, String resultSetMapping) Query<?>
createQuery
(String queryString) If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.<T> Query<T>
createQuery
(String queryString, Class<T> resultType) Query<?>
createQuery
(javax.persistence.criteria.CriteriaDelete criteria) <T> Query<T>
createQuery
(javax.persistence.criteria.CriteriaQuery<T> criteria) Query<?>
createQuery
(javax.persistence.criteria.CriteriaUpdate criteria) NativeQuery<?>
createSQLQuery
(String queryString) If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.createStoredProcedureCall
(String paramString, Class... paramArrayOfClass) createStoredProcedureCall
(String paramString, String... paramArrayOfString) javax.persistence.StoredProcedureQuery
createStoredProcedureQuery
(String procedureName) javax.persistence.StoredProcedureQuery
createStoredProcedureQuery
(String procedureName, Class... resultClasses) javax.persistence.StoredProcedureQuery
createStoredProcedureQuery
(String procedureName, String... resultSetMappings) void
void
void
void
disableFetchProfile
(String name) void
disableFilter
(String filterName) <T> T
doReturningWork
(ReturningWork<T> paramReturningWork) void
void
enableFetchProfile
(String name) enableFilter
(String filterName) void
<T> T
<T> T
<T> T
<T> T
find
(Class<T> entityClass, Object primaryKey, javax.persistence.LockModeType lockMode, Map<String, Object> properties) void
flush()
<T> T
get
(Class<T> clazz, Serializable id) <T> T
get
(Class<T> clazz, Serializable id, LockMode lockMode) <T> T
get
(Class<T> clazz, Serializable id, LockOptions lockOptions) get
(String entityName, Serializable id) get
(String entityName, Serializable id, LockMode lockMode) get
(String entityName, Serializable id, LockOptions lockOptions) javax.persistence.criteria.CriteriaBuilder
getCurrentLockMode
(Object object) getEnabledFilter
(String filterName) RootGraph<?>
getEntityGraph
(String graphName) <T> List<javax.persistence.EntityGraph<? super T>>
getEntityGraphs
(Class<T> entityClass) javax.persistence.EntityManagerFactory
getEntityName
(Object object) javax.persistence.FlushModeType
getIdentifier
(Object object) javax.persistence.LockModeType
getLockMode
(Object entity) javax.persistence.metamodel.Metamodel
NativeQuery<?>
getNamedNativeQuery
(String queryName) getNamedProcedureCall
(String name) Query<?>
getNamedQuery
(String queryName) If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.Get the underlying parent session from Hibernate.<T> T
getReference
(Class<T> entityClass, Object primaryKey) Deprecated.boolean
boolean
boolean
isDirty()
boolean
isFetchProfileEnabled
(String name) boolean
boolean
isOpen()
boolean
isReadOnly
(Object entityOrProxy) void
<T> T
load
(Class<T> theClass, Serializable id) <T> T
load
(Class<T> theClass, Serializable id, LockMode lockMode) <T> T
load
(Class<T> theClass, Serializable id, LockOptions lockOptions) void
load
(Object object, Serializable id) load
(String entityName, Serializable id) load
(String entityName, Serializable id, LockMode lockMode) load
(String entityName, Serializable id, LockOptions lockOptions) void
void
void
void
void
void
void
reconnect
(Connection connection) void
void
void
void
void
void
refresh
(Object object, LockOptions lockOptions) void
void
refresh
(String paramString, Object paramObject, LockOptions paramLockOptions) void
void
replicate
(Object object, ReplicationMode replicationMode) void
replicate
(String entityName, Object object, ReplicationMode replicationMode) void
saveOrUpdate
(Object object) void
saveOrUpdate
(String entityName, Object object) void
setCacheMode
(CacheMode cacheMode) void
setDefaultReadOnly
(boolean readOnly) void
setFlushMode
(javax.persistence.FlushModeType flushMode) void
setFlushMode
(FlushMode flushMode) Deprecated.void
setHibernateFlushMode
(FlushMode flushMode) void
setJdbcBatchSize
(Integer size) void
setProperty
(String propertyName, Object value) void
setReadOnly
(Object entityOrProxy, boolean readOnly) <T> T
void
void
Methods inherited from class net.sf.basedb.core.hibernate.AbstractQueryCache
cacheQuery, getCachedQuery, getCachedQuery
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hibernate.query.QueryProducer
getNamedSQLQuery
Methods inherited from interface org.hibernate.Session
getReference
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
session
-
-
Constructor Details
-
SessionWrapper
Creates a new session wrapper- Parameters:
session
- The real Hibernate session
-
-
Method Details
-
getParentSession
Get the underlying parent session from Hibernate. -
beginTransaction
- Specified by:
beginTransaction
in interfaceSharedSessionContract
- Throws:
HibernateException
-
buildLockRequest
- Specified by:
buildLockRequest
in interfaceSession
-
cancelQuery
- Specified by:
cancelQuery
in interfaceSession
- Throws:
HibernateException
-
clear
public void clear() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacejavax.persistence.EntityManager
- Specified by:
close
in interfaceSharedSessionContract
- Throws:
HibernateException
-
contains
- Specified by:
contains
in interfacejavax.persistence.EntityManager
-
createCriteria
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createCriteria
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createCriteria
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createCriteria
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createFilter
@Deprecated public Query<?> createFilter(Object collection, String queryString) throws HibernateException Deprecated.- Specified by:
createFilter
in interfaceSession
- Throws:
HibernateException
-
createQuery
If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.- Specified by:
createQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSharedSessionContract
- Throws:
HibernateException
-
createSQLQuery
If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.- Specified by:
createSQLQuery
in interfaceQueryProducer
- Specified by:
createSQLQuery
in interfaceSession
- Throws:
HibernateException
-
delete
- Specified by:
delete
in interfaceSession
- Throws:
HibernateException
-
delete
- Specified by:
delete
in interfaceSession
- Throws:
HibernateException
-
disableFetchProfile
- Specified by:
disableFetchProfile
in interfaceSession
- Throws:
UnknownProfileException
-
disableFilter
- Specified by:
disableFilter
in interfaceSession
-
disconnect
- Specified by:
disconnect
in interfaceSession
- Throws:
HibernateException
-
doWork
- Specified by:
doWork
in interfaceSharedSessionContract
- Throws:
HibernateException
-
enableFetchProfile
- Specified by:
enableFetchProfile
in interfaceSession
- Throws:
UnknownProfileException
-
enableFilter
- Specified by:
enableFilter
in interfaceSession
-
evict
- Specified by:
evict
in interfaceSession
- Throws:
HibernateException
-
flush
- Specified by:
flush
in interfacejavax.persistence.EntityManager
- Specified by:
flush
in interfaceSession
- Throws:
HibernateException
-
get
- Specified by:
get
in interfaceSession
- Throws:
HibernateException
-
get
public <T> T get(Class<T> clazz, Serializable id, LockOptions lockOptions) throws HibernateException - Specified by:
get
in interfaceSession
- Throws:
HibernateException
-
get
- Specified by:
get
in interfaceSession
- Throws:
HibernateException
-
get
- Specified by:
get
in interfaceSession
- Throws:
HibernateException
-
get
public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException - Specified by:
get
in interfaceSession
- Throws:
HibernateException
-
get
- Specified by:
get
in interfaceSession
- Throws:
HibernateException
-
getCacheMode
- Specified by:
getCacheMode
in interfaceSession
-
getCurrentLockMode
- Specified by:
getCurrentLockMode
in interfaceSession
- Throws:
HibernateException
-
getEnabledFilter
- Specified by:
getEnabledFilter
in interfaceSession
-
getEntityName
- Specified by:
getEntityName
in interfaceSession
- Throws:
HibernateException
-
getFlushMode
public javax.persistence.FlushModeType getFlushMode()- Specified by:
getFlushMode
in interfacejavax.persistence.EntityManager
- Specified by:
getFlushMode
in interfaceSession
-
getIdentifier
- Specified by:
getIdentifier
in interfaceSession
- Throws:
HibernateException
-
getLobHelper
- Specified by:
getLobHelper
in interfaceSession
-
getNamedQuery
If the same query has been executed before, return the cached instance, otherwise create a new query from the parent session and cache it.- Specified by:
getNamedQuery
in interfaceQueryProducer
- Specified by:
getNamedQuery
in interfaceSharedSessionContract
- Throws:
HibernateException
-
getSessionFactory
- Specified by:
getSessionFactory
in interfaceSession
-
getStatistics
- Specified by:
getStatistics
in interfaceSession
-
getTransaction
- Specified by:
getTransaction
in interfacejavax.persistence.EntityManager
- Specified by:
getTransaction
in interfaceSharedSessionContract
-
getTypeHelper
- Specified by:
getTypeHelper
in interfaceSession
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceSharedSessionContract
-
isDefaultReadOnly
public boolean isDefaultReadOnly()- Specified by:
isDefaultReadOnly
in interfaceSession
-
isDirty
- Specified by:
isDirty
in interfaceSession
- Throws:
HibernateException
-
isFetchProfileEnabled
- Specified by:
isFetchProfileEnabled
in interfaceSession
- Throws:
UnknownProfileException
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfacejavax.persistence.EntityManager
- Specified by:
isOpen
in interfaceSharedSessionContract
-
isReadOnly
- Specified by:
isReadOnly
in interfaceSession
-
load
- Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
public <T> T load(Class<T> theClass, Serializable id, LockOptions lockOptions) throws HibernateException - Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
- Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
- Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
- Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException - Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
load
- Specified by:
load
in interfaceSession
- Throws:
HibernateException
-
lock
- Specified by:
lock
in interfaceSession
- Throws:
HibernateException
-
lock
- Specified by:
lock
in interfaceSession
- Throws:
HibernateException
-
merge
- Specified by:
merge
in interfacejavax.persistence.EntityManager
- Specified by:
merge
in interfaceSession
- Throws:
HibernateException
-
merge
- Specified by:
merge
in interfaceSession
- Throws:
HibernateException
-
persist
- Specified by:
persist
in interfacejavax.persistence.EntityManager
- Specified by:
persist
in interfaceSession
- Throws:
HibernateException
-
persist
- Specified by:
persist
in interfaceSession
- Throws:
HibernateException
-
reconnect
- Specified by:
reconnect
in interfaceSession
- Throws:
HibernateException
-
refresh
- Specified by:
refresh
in interfaceSession
- Throws:
HibernateException
-
refresh
- Specified by:
refresh
in interfaceSession
- Throws:
HibernateException
-
refresh
- Specified by:
refresh
in interfacejavax.persistence.EntityManager
- Specified by:
refresh
in interfaceSession
- Throws:
HibernateException
-
replicate
- Specified by:
replicate
in interfaceSession
- Throws:
HibernateException
-
replicate
public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException - Specified by:
replicate
in interfaceSession
- Throws:
HibernateException
-
save
- Specified by:
save
in interfaceSession
- Throws:
HibernateException
-
save
- Specified by:
save
in interfaceSession
- Throws:
HibernateException
-
saveOrUpdate
- Specified by:
saveOrUpdate
in interfaceSession
- Throws:
HibernateException
-
saveOrUpdate
- Specified by:
saveOrUpdate
in interfaceSession
- Throws:
HibernateException
-
setCacheMode
- Specified by:
setCacheMode
in interfaceSession
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean readOnly) - Specified by:
setDefaultReadOnly
in interfaceSession
-
setFlushMode
Deprecated.- Specified by:
setFlushMode
in interfaceSession
-
setReadOnly
- Specified by:
setReadOnly
in interfaceSession
-
update
- Specified by:
update
in interfaceSession
- Throws:
HibernateException
-
update
- Specified by:
update
in interfaceSession
- Throws:
HibernateException
-
getTenantIdentifier
- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
-
getNamedProcedureCall
- Specified by:
getNamedProcedureCall
in interfaceSharedSessionContract
-
createStoredProcedureCall
- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
-
createStoredProcedureCall
- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
-
createStoredProcedureCall
- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
-
sessionWithOptions
- Specified by:
sessionWithOptions
in interfaceSession
-
refresh
-
refresh
-
byId
-
byId
-
byNaturalId
- Specified by:
byNaturalId
in interfaceSession
-
byNaturalId
- Specified by:
byNaturalId
in interfaceSession
-
bySimpleNaturalId
- Specified by:
bySimpleNaturalId
in interfaceSession
-
bySimpleNaturalId
- Specified by:
bySimpleNaturalId
in interfaceSession
-
doReturningWork
- Specified by:
doReturningWork
in interfaceSharedSessionContract
- Throws:
HibernateException
-
addEventListeners
- Specified by:
addEventListeners
in interfaceSession
-
getJdbcBatchSize
- Specified by:
getJdbcBatchSize
in interfaceSharedSessionContract
-
setJdbcBatchSize
- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
-
byMultipleIds
- Specified by:
byMultipleIds
in interfaceSession
-
byMultipleIds
- Specified by:
byMultipleIds
in interfaceSession
-
contains
-
createNamedQuery
- Specified by:
createNamedQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceSession
-
createQuery
- Specified by:
createQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
createQuery
- Specified by:
createQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
createQuery
- Specified by:
createQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
createQuery
- Specified by:
createQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
getHibernateFlushMode
- Specified by:
getHibernateFlushMode
in interfaceSession
-
setHibernateFlushMode
- Specified by:
setHibernateFlushMode
in interfaceSession
-
createNamedQuery
- Specified by:
createNamedQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createNamedQuery
in interfaceQueryProducer
-
createNativeQuery
- Specified by:
createNativeQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createNativeQuery
- Specified by:
createNativeQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createNativeQuery
- Specified by:
createNativeQuery
in interfacejavax.persistence.EntityManager
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
getNamedNativeQuery
- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
-
createEntityGraph
- Specified by:
createEntityGraph
in interfacejavax.persistence.EntityManager
- Specified by:
createEntityGraph
in interfaceSession
-
createEntityGraph
- Specified by:
createEntityGraph
in interfacejavax.persistence.EntityManager
- Specified by:
createEntityGraph
in interfaceSession
-
createNamedStoredProcedureQuery
- Specified by:
createNamedStoredProcedureQuery
in interfacejavax.persistence.EntityManager
-
createStoredProcedureQuery
public javax.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) - Specified by:
createStoredProcedureQuery
in interfacejavax.persistence.EntityManager
-
createStoredProcedureQuery
public javax.persistence.StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) - Specified by:
createStoredProcedureQuery
in interfacejavax.persistence.EntityManager
-
createStoredProcedureQuery
- Specified by:
createStoredProcedureQuery
in interfacejavax.persistence.EntityManager
-
detach
- Specified by:
detach
in interfacejavax.persistence.EntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, javax.persistence.LockModeType lockMode, Map<String, Object> properties) - Specified by:
find
in interfacejavax.persistence.EntityManager
-
find
- Specified by:
find
in interfacejavax.persistence.EntityManager
-
find
- Specified by:
find
in interfacejavax.persistence.EntityManager
-
find
- Specified by:
find
in interfacejavax.persistence.EntityManager
-
getCriteriaBuilder
public javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()- Specified by:
getCriteriaBuilder
in interfacejavax.persistence.EntityManager
-
getDelegate
- Specified by:
getDelegate
in interfacejavax.persistence.EntityManager
-
getEntityGraph
- Specified by:
getEntityGraph
in interfacejavax.persistence.EntityManager
- Specified by:
getEntityGraph
in interfaceSession
-
getEntityGraphs
- Specified by:
getEntityGraphs
in interfacejavax.persistence.EntityManager
- Specified by:
getEntityGraphs
in interfaceSession
-
getEntityManagerFactory
public javax.persistence.EntityManagerFactory getEntityManagerFactory()- Specified by:
getEntityManagerFactory
in interfacejavax.persistence.EntityManager
-
getLockMode
- Specified by:
getLockMode
in interfacejavax.persistence.EntityManager
-
getMetamodel
public javax.persistence.metamodel.Metamodel getMetamodel()- Specified by:
getMetamodel
in interfacejavax.persistence.EntityManager
-
getProperties
- Specified by:
getProperties
in interfacejavax.persistence.EntityManager
-
getReference
- Specified by:
getReference
in interfacejavax.persistence.EntityManager
-
isJoinedToTransaction
public boolean isJoinedToTransaction()- Specified by:
isJoinedToTransaction
in interfacejavax.persistence.EntityManager
-
joinTransaction
public void joinTransaction()- Specified by:
joinTransaction
in interfacejavax.persistence.EntityManager
-
lock
public void lock(Object entity, javax.persistence.LockModeType lockMode, Map<String, Object> properties) - Specified by:
lock
in interfacejavax.persistence.EntityManager
-
lock
- Specified by:
lock
in interfacejavax.persistence.EntityManager
-
refresh
public void refresh(Object entity, javax.persistence.LockModeType lockMode, Map<String, Object> properties) - Specified by:
refresh
in interfacejavax.persistence.EntityManager
-
refresh
- Specified by:
refresh
in interfacejavax.persistence.EntityManager
-
refresh
- Specified by:
refresh
in interfacejavax.persistence.EntityManager
-
remove
- Specified by:
remove
in interfacejavax.persistence.EntityManager
-
setFlushMode
public void setFlushMode(javax.persistence.FlushModeType flushMode) - Specified by:
setFlushMode
in interfacejavax.persistence.EntityManager
-
setProperty
- Specified by:
setProperty
in interfacejavax.persistence.EntityManager
-
unwrap
- Specified by:
unwrap
in interfacejavax.persistence.EntityManager
-
getSession
Deprecated.- Specified by:
getSession
in interfaceHibernateEntityManager
-