Package net.sf.basedb.core.hibernate
Class StatelessSessionWrapper
java.lang.Object
net.sf.basedb.core.hibernate.AbstractQueryCache
net.sf.basedb.core.hibernate.StatelessSessionWrapper
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,QueryProducer
,SharedSessionContract
,StatelessSession
public class StatelessSessionWrapper extends AbstractQueryCache implements StatelessSession
Wrapper around stateless 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:
- Serialized Form
- Last modified
- $Date: 2019-09-26 15:49:09 +0200 (tors, 26 sep. 2019) $
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
private StatelessSession
session
-
Constructor Summary
Constructors Constructor Description StatelessSessionWrapper(StatelessSession session)
Creates a new session wrapper -
Method Summary
Modifier and Type Method Description Transaction
beginTransaction()
void
cancelQuery()
Cancels the currently executing query in the same manner asSession.cancelQuery()
.void
close()
Connection
connection()
Deprecated.Criteria
createCriteria(Class persistentClass)
Deprecated.Criteria
createCriteria(Class persistentClass, String alias)
Deprecated.Criteria
createCriteria(String entityName)
Deprecated.Criteria
createCriteria(String entityName, String alias)
Deprecated.Query<?>
createNamedQuery(String queryName)
<R> Query<R>
createNamedQuery(String queryName, Class<R> returnType)
NativeQuery<?>
createNativeQuery(String queryString)
<R> NativeQuery<R>
createNativeQuery(String queryString, Class<R> resultClass)
NativeQuery<?>
createNativeQuery(String queryString, 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.<R> Query<R>
createQuery(String queryString, Class<R> resultClass)
Query
createQuery(javax.persistence.criteria.CriteriaDelete c)
<T> Query<T>
createQuery(javax.persistence.criteria.CriteriaQuery<T> c)
Query
createQuery(javax.persistence.criteria.CriteriaUpdate c)
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.ProcedureCall
createStoredProcedureCall(String name)
ProcedureCall
createStoredProcedureCall(String paramString, Class... paramArrayOfClass)
ProcedureCall
createStoredProcedureCall(String paramString, String... paramArrayOfString)
void
delete(Object entity)
void
delete(String entityName, Object entity)
Object
get(Class entityClass, Serializable id)
Object
get(Class entityClass, Serializable id, LockMode lockMode)
Object
get(String entityName, Serializable id)
Object
get(String entityName, Serializable id, LockMode lockMode)
Integer
getJdbcBatchSize()
NativeQuery<?>
getNamedNativeQuery(String queryName)
ProcedureCall
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.StatelessSession
getParentSession()
Get the underlying parent session from Hibernate.String
getTenantIdentifier()
Transaction
getTransaction()
Serializable
insert(Object entity)
Serializable
insert(String entityName, Object entity)
boolean
isConnected()
boolean
isOpen()
void
refresh(Object entity)
void
refresh(Object entity, LockMode lockMode)
void
refresh(String entityName, Object entity)
void
refresh(String entityName, Object entity, LockMode lockMode)
void
setJdbcBatchSize(Integer batchSize)
void
update(Object entity)
void
update(String entityName, Object entity)
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.SharedSessionContract
doReturningWork, doWork
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
session
-
-
Constructor Details
-
StatelessSessionWrapper
Creates a new session wrapper- Parameters:
session
- The real Hibernate session
-
-
Method Details
-
getParentSession
Get the underlying parent session from Hibernate. -
cancelQuery
Cancels the currently executing query in the same manner asSession.cancelQuery()
. Since this method is not part of the StatelessSession interface this only works if the underlying parent session is the Hibernate implementation.- Throws:
HibernateException
-
beginTransaction
- Specified by:
beginTransaction
in interfaceSharedSessionContract
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSharedSessionContract
- Specified by:
close
in interfaceStatelessSession
-
connection
Deprecated.- Specified by:
connection
in interfaceStatelessSession
-
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
-
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 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 interfaceStatelessSession
- Throws:
HibernateException
-
delete
- Specified by:
delete
in interfaceStatelessSession
-
delete
- Specified by:
delete
in interfaceStatelessSession
-
get
- Specified by:
get
in interfaceStatelessSession
-
get
- Specified by:
get
in interfaceStatelessSession
-
get
- Specified by:
get
in interfaceStatelessSession
-
get
- Specified by:
get
in interfaceStatelessSession
-
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
-
getTransaction
- Specified by:
getTransaction
in interfaceSharedSessionContract
-
insert
- Specified by:
insert
in interfaceStatelessSession
-
insert
- Specified by:
insert
in interfaceStatelessSession
-
refresh
- Specified by:
refresh
in interfaceStatelessSession
-
refresh
- Specified by:
refresh
in interfaceStatelessSession
-
refresh
- Specified by:
refresh
in interfaceStatelessSession
-
refresh
- Specified by:
refresh
in interfaceStatelessSession
-
update
- Specified by:
update
in interfaceStatelessSession
-
update
- Specified by:
update
in interfaceStatelessSession
-
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
-
getJdbcBatchSize
- Specified by:
getJdbcBatchSize
in interfaceSharedSessionContract
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceSharedSessionContract
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceSharedSessionContract
-
setJdbcBatchSize
- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
-
createNamedQuery
- Specified by:
createNamedQuery
in interfaceQueryProducer
-
createNamedQuery
- Specified by:
createNamedQuery
in interfaceQueryProducer
-
createNativeQuery
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createNativeQuery
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createNativeQuery
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createQuery
- Specified by:
createQuery
in interfaceQueryProducer
-
getNamedNativeQuery
- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
-
createQuery
- Specified by:
createQuery
in interfaceQueryProducer
-
createQuery
- Specified by:
createQuery
in interfaceQueryProducer
-
createQuery
- Specified by:
createQuery
in interfaceQueryProducer
-