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: 2018-11-06 15:50:29 +0100 (ti, 06 nov 2018) $
-
-
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
All Methods Instance Methods Concrete Methods Deprecated Methods 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)
SQLQuery<?>
createSQLQuery(String queryString)
Deprecated.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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
session
private final StatelessSession session
-
-
Constructor Detail
-
StatelessSessionWrapper
public StatelessSessionWrapper(StatelessSession session)
Creates a new session wrapper- Parameters:
session
- The real Hibernate session
-
-
Method Detail
-
getParentSession
public StatelessSession getParentSession()
Get the underlying parent session from Hibernate.
-
cancelQuery
public void cancelQuery() throws HibernateException
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
public Transaction 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 public Connection connection()
Deprecated.- Specified by:
connection
in interfaceStatelessSession
-
createCriteria
@Deprecated public Criteria createCriteria(Class persistentClass, String alias)
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createCriteria
@Deprecated public Criteria createCriteria(Class persistentClass)
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createCriteria
@Deprecated public Criteria createCriteria(String entityName, String alias)
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createCriteria
@Deprecated public Criteria createCriteria(String entityName)
Deprecated.- Specified by:
createCriteria
in interfaceSharedSessionContract
-
createQuery
public Query<?> createQuery(String queryString) throws HibernateException
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
- Throws:
HibernateException
-
createSQLQuery
@Deprecated public SQLQuery<?> createSQLQuery(String queryString) throws HibernateException
Deprecated.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
- Throws:
HibernateException
-
delete
public void delete(Object entity)
- Specified by:
delete
in interfaceStatelessSession
-
delete
public void delete(String entityName, Object entity)
- Specified by:
delete
in interfaceStatelessSession
-
get
public Object get(Class entityClass, Serializable id, LockMode lockMode)
- Specified by:
get
in interfaceStatelessSession
-
get
public Object get(Class entityClass, Serializable id)
- Specified by:
get
in interfaceStatelessSession
-
get
public Object get(String entityName, Serializable id, LockMode lockMode)
- Specified by:
get
in interfaceStatelessSession
-
get
public Object get(String entityName, Serializable id)
- Specified by:
get
in interfaceStatelessSession
-
getNamedQuery
public Query<?> getNamedQuery(String queryName) throws HibernateException
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
- Throws:
HibernateException
-
getTransaction
public Transaction getTransaction()
- Specified by:
getTransaction
in interfaceSharedSessionContract
-
insert
public Serializable insert(Object entity)
- Specified by:
insert
in interfaceStatelessSession
-
insert
public Serializable insert(String entityName, Object entity)
- Specified by:
insert
in interfaceStatelessSession
-
refresh
public void refresh(Object entity, LockMode lockMode)
- Specified by:
refresh
in interfaceStatelessSession
-
refresh
public void refresh(Object entity)
- Specified by:
refresh
in interfaceStatelessSession
-
refresh
public void refresh(String entityName, Object entity, LockMode lockMode)
- Specified by:
refresh
in interfaceStatelessSession
-
refresh
public void refresh(String entityName, Object entity)
- Specified by:
refresh
in interfaceStatelessSession
-
update
public void update(Object entity)
- Specified by:
update
in interfaceStatelessSession
-
update
public void update(String entityName, Object entity)
- Specified by:
update
in interfaceStatelessSession
-
getTenantIdentifier
public String getTenantIdentifier()
- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(String name)
- Specified by:
getNamedProcedureCall
in interfaceSharedSessionContract
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String name)
- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String paramString, Class... paramArrayOfClass)
- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String paramString, String... paramArrayOfString)
- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
-
getJdbcBatchSize
public Integer 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
public void setJdbcBatchSize(Integer batchSize)
- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
-
createNamedQuery
public <R> Query<R> createNamedQuery(String queryName, Class<R> returnType)
- Specified by:
createNamedQuery
in interfaceQueryProducer
-
createNamedQuery
public Query<?> createNamedQuery(String queryName)
- Specified by:
createNamedQuery
in interfaceQueryProducer
-
createNativeQuery
public <R> NativeQuery<R> createNativeQuery(String queryString, Class<R> resultClass)
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createNativeQuery
public NativeQuery<?> createNativeQuery(String queryString, String resultSetMapping)
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createNativeQuery
public NativeQuery<?> createNativeQuery(String queryString)
- Specified by:
createNativeQuery
in interfaceQueryProducer
-
createQuery
public <R> Query<R> createQuery(String queryString, Class<R> resultClass)
- Specified by:
createQuery
in interfaceQueryProducer
-
getNamedNativeQuery
public NativeQuery<?> getNamedNativeQuery(String queryName)
- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
-
-