3.0.4: 2012-03-05

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, 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: 2010-06-10 10:54:19 +0200 (Thu, 10 Jun 2010) $

Field Summary
private static long serialVersionUID
           
private  StatelessSession session
           
 
Constructor Summary
StatelessSessionWrapper(StatelessSession session)
          Creates a new session wrapper
 
Method Summary
 Transaction beginTransaction()
           
 void cancelQuery()
          Cancels the currently executing query in the same manner as Session.cancelQuery().
 void close()
           
 Connection connection()
           
 Criteria createCriteria(Class persistentClass)
           
 Criteria createCriteria(Class persistentClass, String alias)
           
 Criteria createCriteria(String entityName)
           
 Criteria createCriteria(String entityName, String alias)
           
 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.
 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, LockMode lockMode)
           
 Object get(String entityName, Serializable id)
           
 Object get(String entityName, Serializable id, LockMode lockMode)
           
 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.
 Transaction getTransaction()
           
 Serializable insert(Object entity)
           
 Serializable insert(String entityName, Object entity)
           
 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 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 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 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:
HibernateException

beginTransaction

public Transaction beginTransaction()
Specified by:
beginTransaction in interface StatelessSession

close

public void close()
Specified by:
close in interface StatelessSession

connection

public Connection connection()
Specified by:
connection in interface StatelessSession

createCriteria

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

createCriteria

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

createCriteria

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

createCriteria

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

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

createSQLQuery

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

delete

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

delete

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

get

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

get

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

get

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

get

public Object get(String entityName,
                  Serializable id)
Specified by:
get in interface StatelessSession

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

getTransaction

public Transaction getTransaction()
Specified by:
getTransaction in interface StatelessSession

insert

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

insert

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

refresh

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

refresh

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

refresh

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

refresh

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

update

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

update

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

3.0.4: 2012-03-05