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
,org.hibernate.query.QueryProducer
,org.hibernate.SharedSessionContract
,org.hibernate.StatelessSession
public class StatelessSessionWrapper extends AbstractQueryCache implements org.hibernate.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 org.hibernate.StatelessSession
session
-
Constructor Summary
Constructors Constructor Description StatelessSessionWrapper(org.hibernate.StatelessSession session)
Creates a new session wrapper
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.hibernate.Transaction
beginTransaction()
void
cancelQuery()
Cancels the currently executing query in the same manner asSession.cancelQuery()
.void
close()
Connection
connection()
Deprecated.org.hibernate.Criteria
createCriteria(Class persistentClass)
Deprecated.org.hibernate.Criteria
createCriteria(Class persistentClass, String alias)
Deprecated.org.hibernate.Criteria
createCriteria(String entityName)
Deprecated.org.hibernate.Criteria
createCriteria(String entityName, String alias)
Deprecated.org.hibernate.query.Query<?>
createNamedQuery(String queryName)
<R> org.hibernate.query.Query<R>
createNamedQuery(String queryName, Class<R> returnType)
org.hibernate.query.NativeQuery<?>
createNativeQuery(String queryString)
<R> org.hibernate.query.NativeQuery<R>
createNativeQuery(String queryString, Class<R> resultClass)
org.hibernate.query.NativeQuery<?>
createNativeQuery(String queryString, String resultSetMapping)
org.hibernate.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> org.hibernate.query.Query<R>
createQuery(String queryString, Class<R> resultClass)
org.hibernate.SQLQuery<?>
createSQLQuery(String queryString)
Deprecated.org.hibernate.procedure.ProcedureCall
createStoredProcedureCall(String name)
org.hibernate.procedure.ProcedureCall
createStoredProcedureCall(String paramString, Class... paramArrayOfClass)
org.hibernate.procedure.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, org.hibernate.LockMode lockMode)
Object
get(String entityName, Serializable id)
Object
get(String entityName, Serializable id, org.hibernate.LockMode lockMode)
Integer
getJdbcBatchSize()
org.hibernate.query.NativeQuery<?>
getNamedNativeQuery(String queryName)
org.hibernate.procedure.ProcedureCall
getNamedProcedureCall(String name)
org.hibernate.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.org.hibernate.StatelessSession
getParentSession()
Get the underlying parent session from Hibernate.String
getTenantIdentifier()
org.hibernate.Transaction
getTransaction()
Serializable
insert(Object entity)
Serializable
insert(String entityName, Object entity)
boolean
isConnected()
boolean
isOpen()
void
refresh(Object entity)
void
refresh(Object entity, org.hibernate.LockMode lockMode)
void
refresh(String entityName, Object entity)
void
refresh(String entityName, Object entity, org.hibernate.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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
session
private final org.hibernate.StatelessSession session
-
-
Method Detail
-
getParentSession
public org.hibernate.StatelessSession getParentSession()
Get the underlying parent session from Hibernate.
-
cancelQuery
public void cancelQuery() throws org.hibernate.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:
org.hibernate.HibernateException
-
beginTransaction
public org.hibernate.Transaction beginTransaction()
- Specified by:
beginTransaction
in interfaceorg.hibernate.SharedSessionContract
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.hibernate.SharedSessionContract
- Specified by:
close
in interfaceorg.hibernate.StatelessSession
-
connection
@Deprecated public Connection connection()
Deprecated.- Specified by:
connection
in interfaceorg.hibernate.StatelessSession
-
createCriteria
@Deprecated public org.hibernate.Criteria createCriteria(Class persistentClass, String alias)
Deprecated.- Specified by:
createCriteria
in interfaceorg.hibernate.SharedSessionContract
-
createCriteria
@Deprecated public org.hibernate.Criteria createCriteria(Class persistentClass)
Deprecated.- Specified by:
createCriteria
in interfaceorg.hibernate.SharedSessionContract
-
createCriteria
@Deprecated public org.hibernate.Criteria createCriteria(String entityName, String alias)
Deprecated.- Specified by:
createCriteria
in interfaceorg.hibernate.SharedSessionContract
-
createCriteria
@Deprecated public org.hibernate.Criteria createCriteria(String entityName)
Deprecated.- Specified by:
createCriteria
in interfaceorg.hibernate.SharedSessionContract
-
createQuery
public org.hibernate.Query<?> createQuery(String queryString) throws org.hibernate.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 interfaceorg.hibernate.query.QueryProducer
- Throws:
org.hibernate.HibernateException
-
createSQLQuery
@Deprecated public org.hibernate.SQLQuery<?> createSQLQuery(String queryString) throws org.hibernate.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 interfaceorg.hibernate.query.QueryProducer
- Throws:
org.hibernate.HibernateException
-
delete
public void delete(Object entity)
- Specified by:
delete
in interfaceorg.hibernate.StatelessSession
-
delete
public void delete(String entityName, Object entity)
- Specified by:
delete
in interfaceorg.hibernate.StatelessSession
-
get
public Object get(Class entityClass, Serializable id, org.hibernate.LockMode lockMode)
- Specified by:
get
in interfaceorg.hibernate.StatelessSession
-
get
public Object get(Class entityClass, Serializable id)
- Specified by:
get
in interfaceorg.hibernate.StatelessSession
-
get
public Object get(String entityName, Serializable id, org.hibernate.LockMode lockMode)
- Specified by:
get
in interfaceorg.hibernate.StatelessSession
-
get
public Object get(String entityName, Serializable id)
- Specified by:
get
in interfaceorg.hibernate.StatelessSession
-
getNamedQuery
public org.hibernate.Query<?> getNamedQuery(String queryName) throws org.hibernate.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 interfaceorg.hibernate.query.QueryProducer
- Throws:
org.hibernate.HibernateException
-
getTransaction
public org.hibernate.Transaction getTransaction()
- Specified by:
getTransaction
in interfaceorg.hibernate.SharedSessionContract
-
insert
public Serializable insert(Object entity)
- Specified by:
insert
in interfaceorg.hibernate.StatelessSession
-
insert
public Serializable insert(String entityName, Object entity)
- Specified by:
insert
in interfaceorg.hibernate.StatelessSession
-
refresh
public void refresh(Object entity, org.hibernate.LockMode lockMode)
- Specified by:
refresh
in interfaceorg.hibernate.StatelessSession
-
refresh
public void refresh(Object entity)
- Specified by:
refresh
in interfaceorg.hibernate.StatelessSession
-
refresh
public void refresh(String entityName, Object entity, org.hibernate.LockMode lockMode)
- Specified by:
refresh
in interfaceorg.hibernate.StatelessSession
-
refresh
public void refresh(String entityName, Object entity)
- Specified by:
refresh
in interfaceorg.hibernate.StatelessSession
-
update
public void update(Object entity)
- Specified by:
update
in interfaceorg.hibernate.StatelessSession
-
update
public void update(String entityName, Object entity)
- Specified by:
update
in interfaceorg.hibernate.StatelessSession
-
getTenantIdentifier
public String getTenantIdentifier()
- Specified by:
getTenantIdentifier
in interfaceorg.hibernate.SharedSessionContract
-
getNamedProcedureCall
public org.hibernate.procedure.ProcedureCall getNamedProcedureCall(String name)
- Specified by:
getNamedProcedureCall
in interfaceorg.hibernate.SharedSessionContract
-
createStoredProcedureCall
public org.hibernate.procedure.ProcedureCall createStoredProcedureCall(String name)
- Specified by:
createStoredProcedureCall
in interfaceorg.hibernate.SharedSessionContract
-
createStoredProcedureCall
public org.hibernate.procedure.ProcedureCall createStoredProcedureCall(String paramString, Class... paramArrayOfClass)
- Specified by:
createStoredProcedureCall
in interfaceorg.hibernate.SharedSessionContract
-
createStoredProcedureCall
public org.hibernate.procedure.ProcedureCall createStoredProcedureCall(String paramString, String... paramArrayOfString)
- Specified by:
createStoredProcedureCall
in interfaceorg.hibernate.SharedSessionContract
-
getJdbcBatchSize
public Integer getJdbcBatchSize()
- Specified by:
getJdbcBatchSize
in interfaceorg.hibernate.SharedSessionContract
-
isConnected
public boolean isConnected()
- Specified by:
isConnected
in interfaceorg.hibernate.SharedSessionContract
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceorg.hibernate.SharedSessionContract
-
setJdbcBatchSize
public void setJdbcBatchSize(Integer batchSize)
- Specified by:
setJdbcBatchSize
in interfaceorg.hibernate.SharedSessionContract
-
createNamedQuery
public <R> org.hibernate.query.Query<R> createNamedQuery(String queryName, Class<R> returnType)
- Specified by:
createNamedQuery
in interfaceorg.hibernate.query.QueryProducer
-
createNamedQuery
public org.hibernate.query.Query<?> createNamedQuery(String queryName)
- Specified by:
createNamedQuery
in interfaceorg.hibernate.query.QueryProducer
-
createNativeQuery
public <R> org.hibernate.query.NativeQuery<R> createNativeQuery(String queryString, Class<R> resultClass)
- Specified by:
createNativeQuery
in interfaceorg.hibernate.query.QueryProducer
-
createNativeQuery
public org.hibernate.query.NativeQuery<?> createNativeQuery(String queryString, String resultSetMapping)
- Specified by:
createNativeQuery
in interfaceorg.hibernate.query.QueryProducer
-
createNativeQuery
public org.hibernate.query.NativeQuery<?> createNativeQuery(String queryString)
- Specified by:
createNativeQuery
in interfaceorg.hibernate.query.QueryProducer
-
createQuery
public <R> org.hibernate.query.Query<R> createQuery(String queryString, Class<R> resultClass)
- Specified by:
createQuery
in interfaceorg.hibernate.query.QueryProducer
-
getNamedNativeQuery
public org.hibernate.query.NativeQuery<?> getNamedNativeQuery(String queryName)
- Specified by:
getNamedNativeQuery
in interfaceorg.hibernate.query.QueryProducer
-
-