2.17.2: 2011-06-17

net.sf.basedb.core.hibernate
Class StatelessSessionWrapper

java.lang.Object
  extended by net.sf.basedb.core.hibernate.AbstractQueryCache
      extended by net.sf.basedb.core.hibernate.StatelessSessionWrapper
All Implemented Interfaces:
Serializable, 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: 2010-06-10 10:54:19 +0200 (Thu, 10 Jun 2010) $

Field Summary
private static long serialVersionUID
           
private  org.hibernate.StatelessSession session
           
 
Constructor Summary
StatelessSessionWrapper(org.hibernate.StatelessSession session)
          Creates a new session wrapper
 
Method Summary
 org.hibernate.Transaction beginTransaction()
           
 void cancelQuery()
          Cancels the currently executing query in the same manner as Session.cancelQuery().
 void close()
           
 Connection connection()
           
 org.hibernate.Criteria createCriteria(Class persistentClass)
           
 org.hibernate.Criteria createCriteria(Class persistentClass, String alias)
           
 org.hibernate.Criteria createCriteria(String entityName)
           
 org.hibernate.Criteria createCriteria(String entityName, String alias)
           
 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.
 org.hibernate.SQLQuery 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.
 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)
           
 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.
 org.hibernate.Transaction getTransaction()
           
 Serializable insert(Object entity)
           
 Serializable insert(String entityName, Object entity)
           
 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 update(Object entity)
           
 void update(String entityName, Object entity)
           
 
Methods inherited from class net.sf.basedb.core.hibernate.AbstractQueryCache
cacheQuery, getCachedQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

session

private final org.hibernate.StatelessSession session
Constructor Detail

StatelessSessionWrapper

public StatelessSessionWrapper(org.hibernate.StatelessSession session)
Creates a new session wrapper

Parameters:
session - The real Hibernate 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 as Session.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 interface org.hibernate.StatelessSession

close

public void close()
Specified by:
close in interface org.hibernate.StatelessSession

connection

public Connection connection()
Specified by:
connection in interface org.hibernate.StatelessSession

createCriteria

public org.hibernate.Criteria createCriteria(Class persistentClass,
                                             String alias)
Specified by:
createCriteria in interface org.hibernate.StatelessSession

createCriteria

public org.hibernate.Criteria createCriteria(Class persistentClass)
Specified by:
createCriteria in interface org.hibernate.StatelessSession

createCriteria

public org.hibernate.Criteria createCriteria(String entityName,
                                             String alias)
Specified by:
createCriteria in interface org.hibernate.StatelessSession

createCriteria

public org.hibernate.Criteria createCriteria(String entityName)
Specified by:
createCriteria in interface org.hibernate.StatelessSession

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 interface org.hibernate.StatelessSession
Throws:
org.hibernate.HibernateException

createSQLQuery

public org.hibernate.SQLQuery createSQLQuery(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:
createSQLQuery in interface org.hibernate.StatelessSession
Throws:
org.hibernate.HibernateException

delete

public void delete(Object entity)
Specified by:
delete in interface org.hibernate.StatelessSession

delete

public void delete(String entityName,
                   Object entity)
Specified by:
delete in interface org.hibernate.StatelessSession

get

public Object get(Class entityClass,
                  Serializable id,
                  org.hibernate.LockMode lockMode)
Specified by:
get in interface org.hibernate.StatelessSession

get

public Object get(Class entityClass,
                  Serializable id)
Specified by:
get in interface org.hibernate.StatelessSession

get

public Object get(String entityName,
                  Serializable id,
                  org.hibernate.LockMode lockMode)
Specified by:
get in interface org.hibernate.StatelessSession

get

public Object get(String entityName,
                  Serializable id)
Specified by:
get in interface org.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 interface org.hibernate.StatelessSession
Throws:
org.hibernate.HibernateException

getTransaction

public org.hibernate.Transaction getTransaction()
Specified by:
getTransaction in interface org.hibernate.StatelessSession

insert

public Serializable insert(Object entity)
Specified by:
insert in interface org.hibernate.StatelessSession

insert

public Serializable insert(String entityName,
                           Object entity)
Specified by:
insert in interface org.hibernate.StatelessSession

refresh

public void refresh(Object entity,
                    org.hibernate.LockMode lockMode)
Specified by:
refresh in interface org.hibernate.StatelessSession

refresh

public void refresh(Object entity)
Specified by:
refresh in interface org.hibernate.StatelessSession

refresh

public void refresh(String entityName,
                    Object entity,
                    org.hibernate.LockMode lockMode)
Specified by:
refresh in interface org.hibernate.StatelessSession

refresh

public void refresh(String entityName,
                    Object entity)
Specified by:
refresh in interface org.hibernate.StatelessSession

update

public void update(Object entity)
Specified by:
update in interface org.hibernate.StatelessSession

update

public void update(String entityName,
                   Object entity)
Specified by:
update in interface org.hibernate.StatelessSession

2.17.2: 2011-06-17