2.17.2: 2011-06-17

net.sf.basedb.core.hibernate
Class SessionWrapper

java.lang.Object
  extended by net.sf.basedb.core.hibernate.AbstractQueryCache
      extended by net.sf.basedb.core.hibernate.SessionWrapper
All Implemented Interfaces:
Serializable, org.hibernate.Session

public class SessionWrapper
extends AbstractQueryCache
implements org.hibernate.Session

Wrapper around 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-11-03 15:02:49 +0100 (Wed, 03 Nov 2010) $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hibernate.Session
org.hibernate.Session.LockRequest
 
Field Summary
private static long serialVersionUID
           
private  org.hibernate.Session session
           
 
Constructor Summary
SessionWrapper(org.hibernate.Session session)
          Creates a new session wrapper
 
Method Summary
 org.hibernate.Transaction beginTransaction()
           
 org.hibernate.Session.LockRequest buildLockRequest(org.hibernate.LockOptions options)
           
 void cancelQuery()
           
 void clear()
           
 Connection close()
           
 Connection connection()
          Deprecated. 
 boolean contains(Object object)
           
 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 createFilter(Object collection, String queryString)
           
 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 object)
           
 void delete(String entityName, Object object)
           
 void disableFetchProfile(String name)
           
 void disableFilter(String filterName)
           
 Connection disconnect()
           
 void doWork(org.hibernate.jdbc.Work work)
           
 void enableFetchProfile(String name)
           
 org.hibernate.Filter enableFilter(String filterName)
           
 void evict(Object object)
           
 void flush()
           
 Object get(Class clazz, Serializable id)
           
 Object get(Class clazz, Serializable id, org.hibernate.LockMode lockMode)
          Deprecated. 
 Object get(Class clazz, Serializable id, org.hibernate.LockOptions lockOptions)
           
 Object get(String entityName, Serializable id)
           
 Object get(String entityName, Serializable id, org.hibernate.LockMode lockMode)
          Deprecated. 
 Object get(String entityName, Serializable id, org.hibernate.LockOptions lockOptions)
           
 org.hibernate.CacheMode getCacheMode()
           
 org.hibernate.LockMode getCurrentLockMode(Object object)
           
 org.hibernate.Filter getEnabledFilter(String filterName)
           
 org.hibernate.EntityMode getEntityMode()
           
 String getEntityName(Object object)
           
 org.hibernate.FlushMode getFlushMode()
           
 Serializable getIdentifier(Object object)
           
 org.hibernate.LobHelper getLobHelper()
           
 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.Session getParentSession()
          Get the underlying parent session from Hibernate.
 org.hibernate.Session getSession(org.hibernate.EntityMode entityMode)
           
 org.hibernate.SessionFactory getSessionFactory()
           
 org.hibernate.stat.SessionStatistics getStatistics()
           
 org.hibernate.Transaction getTransaction()
           
 org.hibernate.TypeHelper getTypeHelper()
           
 boolean isConnected()
           
 boolean isDefaultReadOnly()
           
 boolean isDirty()
           
 boolean isFetchProfileEnabled(String name)
           
 boolean isOpen()
           
 boolean isReadOnly(Object entityOrProxy)
           
 Object load(Class theClass, Serializable id)
           
 Object load(Class theClass, Serializable id, org.hibernate.LockMode lockMode)
          Deprecated. 
 Object load(Class theClass, Serializable id, org.hibernate.LockOptions lockOptions)
           
 void load(Object object, Serializable id)
           
 Object load(String entityName, Serializable id)
           
 Object load(String entityName, Serializable id, org.hibernate.LockMode lockMode)
          Deprecated. 
 Object load(String entityName, Serializable id, org.hibernate.LockOptions lockOptions)
           
 void lock(Object object, org.hibernate.LockMode lockMode)
          Deprecated. 
 void lock(String entityName, Object object, org.hibernate.LockMode lockMode)
          Deprecated. 
 Object merge(Object object)
           
 Object merge(String entityName, Object object)
           
 void persist(Object object)
           
 void persist(String entityName, Object object)
           
 void reconnect()
          Deprecated. 
 void reconnect(Connection connection)
           
 void refresh(Object object)
           
 void refresh(Object object, org.hibernate.LockMode lockMode)
          Deprecated. 
 void refresh(Object object, org.hibernate.LockOptions lockOptions)
           
 void replicate(Object object, org.hibernate.ReplicationMode replicationMode)
           
 void replicate(String entityName, Object object, org.hibernate.ReplicationMode replicationMode)
           
 Serializable save(Object object)
           
 Serializable save(String entityName, Object object)
           
 void saveOrUpdate(Object object)
           
 void saveOrUpdate(String entityName, Object object)
           
 void setCacheMode(org.hibernate.CacheMode cacheMode)
           
 void setDefaultReadOnly(boolean readOnly)
           
 void setFlushMode(org.hibernate.FlushMode flushMode)
           
 void setReadOnly(Object entityOrProxy, boolean readOnly)
           
 void update(Object object)
           
 void update(String entityName, Object object)
           
 
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.Session session
Constructor Detail

SessionWrapper

public SessionWrapper(org.hibernate.Session session)
Creates a new session wrapper

Parameters:
session - The real Hibernate session
Method Detail

getParentSession

public org.hibernate.Session getParentSession()
Get the underlying parent session from Hibernate.


beginTransaction

public org.hibernate.Transaction beginTransaction()
                                           throws org.hibernate.HibernateException
Specified by:
beginTransaction in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

buildLockRequest

public org.hibernate.Session.LockRequest buildLockRequest(org.hibernate.LockOptions options)
Specified by:
buildLockRequest in interface org.hibernate.Session

cancelQuery

public void cancelQuery()
                 throws org.hibernate.HibernateException
Specified by:
cancelQuery in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

clear

public void clear()
Specified by:
clear in interface org.hibernate.Session

close

public Connection close()
                 throws org.hibernate.HibernateException
Specified by:
close in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

connection

@Deprecated
public Connection connection()
                      throws org.hibernate.HibernateException
Deprecated. 

Specified by:
connection in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

contains

public boolean contains(Object object)
Specified by:
contains in interface org.hibernate.Session

createCriteria

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

createCriteria

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

createCriteria

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

createCriteria

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

createFilter

public org.hibernate.Query createFilter(Object collection,
                                        String queryString)
                                 throws org.hibernate.HibernateException
Specified by:
createFilter in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

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

delete

public void delete(Object object)
            throws org.hibernate.HibernateException
Specified by:
delete in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

delete

public void delete(String entityName,
                   Object object)
            throws org.hibernate.HibernateException
Specified by:
delete in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

disableFetchProfile

public void disableFetchProfile(String name)
                         throws org.hibernate.UnknownProfileException
Specified by:
disableFetchProfile in interface org.hibernate.Session
Throws:
org.hibernate.UnknownProfileException

disableFilter

public void disableFilter(String filterName)
Specified by:
disableFilter in interface org.hibernate.Session

disconnect

public Connection disconnect()
                      throws org.hibernate.HibernateException
Specified by:
disconnect in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

doWork

public void doWork(org.hibernate.jdbc.Work work)
            throws org.hibernate.HibernateException
Specified by:
doWork in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

enableFetchProfile

public void enableFetchProfile(String name)
                        throws org.hibernate.UnknownProfileException
Specified by:
enableFetchProfile in interface org.hibernate.Session
Throws:
org.hibernate.UnknownProfileException

enableFilter

public org.hibernate.Filter enableFilter(String filterName)
Specified by:
enableFilter in interface org.hibernate.Session

evict

public void evict(Object object)
           throws org.hibernate.HibernateException
Specified by:
evict in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

flush

public void flush()
           throws org.hibernate.HibernateException
Specified by:
flush in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

get

@Deprecated
public Object get(Class clazz,
                             Serializable id,
                             org.hibernate.LockMode lockMode)
           throws org.hibernate.HibernateException
Deprecated. 

Specified by:
get in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

get

public Object get(Class clazz,
                  Serializable id,
                  org.hibernate.LockOptions lockOptions)
           throws org.hibernate.HibernateException
Specified by:
get in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

get

public Object get(Class clazz,
                  Serializable id)
           throws org.hibernate.HibernateException
Specified by:
get in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

get

@Deprecated
public Object get(String entityName,
                             Serializable id,
                             org.hibernate.LockMode lockMode)
           throws org.hibernate.HibernateException
Deprecated. 

Specified by:
get in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

get

public Object get(String entityName,
                  Serializable id,
                  org.hibernate.LockOptions lockOptions)
           throws org.hibernate.HibernateException
Specified by:
get in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

get

public Object get(String entityName,
                  Serializable id)
           throws org.hibernate.HibernateException
Specified by:
get in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

getCacheMode

public org.hibernate.CacheMode getCacheMode()
Specified by:
getCacheMode in interface org.hibernate.Session

getCurrentLockMode

public org.hibernate.LockMode getCurrentLockMode(Object object)
                                          throws org.hibernate.HibernateException
Specified by:
getCurrentLockMode in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

getEnabledFilter

public org.hibernate.Filter getEnabledFilter(String filterName)
Specified by:
getEnabledFilter in interface org.hibernate.Session

getEntityMode

public org.hibernate.EntityMode getEntityMode()
Specified by:
getEntityMode in interface org.hibernate.Session

getEntityName

public String getEntityName(Object object)
                     throws org.hibernate.HibernateException
Specified by:
getEntityName in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

getFlushMode

public org.hibernate.FlushMode getFlushMode()
Specified by:
getFlushMode in interface org.hibernate.Session

getIdentifier

public Serializable getIdentifier(Object object)
                           throws org.hibernate.HibernateException
Specified by:
getIdentifier in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

getLobHelper

public org.hibernate.LobHelper getLobHelper()
Specified by:
getLobHelper in interface org.hibernate.Session

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

getSession

public org.hibernate.Session getSession(org.hibernate.EntityMode entityMode)
Specified by:
getSession in interface org.hibernate.Session

getSessionFactory

public org.hibernate.SessionFactory getSessionFactory()
Specified by:
getSessionFactory in interface org.hibernate.Session

getStatistics

public org.hibernate.stat.SessionStatistics getStatistics()
Specified by:
getStatistics in interface org.hibernate.Session

getTransaction

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

getTypeHelper

public org.hibernate.TypeHelper getTypeHelper()
Specified by:
getTypeHelper in interface org.hibernate.Session

isConnected

public boolean isConnected()
Specified by:
isConnected in interface org.hibernate.Session

isDefaultReadOnly

public boolean isDefaultReadOnly()
Specified by:
isDefaultReadOnly in interface org.hibernate.Session

isDirty

public boolean isDirty()
                throws org.hibernate.HibernateException
Specified by:
isDirty in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

isFetchProfileEnabled

public boolean isFetchProfileEnabled(String name)
                              throws org.hibernate.UnknownProfileException
Specified by:
isFetchProfileEnabled in interface org.hibernate.Session
Throws:
org.hibernate.UnknownProfileException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface org.hibernate.Session

isReadOnly

public boolean isReadOnly(Object entityOrProxy)
Specified by:
isReadOnly in interface org.hibernate.Session

load

@Deprecated
public Object load(Class theClass,
                              Serializable id,
                              org.hibernate.LockMode lockMode)
            throws org.hibernate.HibernateException
Deprecated. 

Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

load

public Object load(Class theClass,
                   Serializable id,
                   org.hibernate.LockOptions lockOptions)
            throws org.hibernate.HibernateException
Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

load

public Object load(Class theClass,
                   Serializable id)
            throws org.hibernate.HibernateException
Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

load

public void load(Object object,
                 Serializable id)
          throws org.hibernate.HibernateException
Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

load

@Deprecated
public Object load(String entityName,
                              Serializable id,
                              org.hibernate.LockMode lockMode)
            throws org.hibernate.HibernateException
Deprecated. 

Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

load

public Object load(String entityName,
                   Serializable id,
                   org.hibernate.LockOptions lockOptions)
            throws org.hibernate.HibernateException
Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

load

public Object load(String entityName,
                   Serializable id)
            throws org.hibernate.HibernateException
Specified by:
load in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

lock

@Deprecated
public void lock(Object object,
                            org.hibernate.LockMode lockMode)
          throws org.hibernate.HibernateException
Deprecated. 

Specified by:
lock in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

lock

@Deprecated
public void lock(String entityName,
                            Object object,
                            org.hibernate.LockMode lockMode)
          throws org.hibernate.HibernateException
Deprecated. 

Specified by:
lock in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

merge

public Object merge(Object object)
             throws org.hibernate.HibernateException
Specified by:
merge in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

merge

public Object merge(String entityName,
                    Object object)
             throws org.hibernate.HibernateException
Specified by:
merge in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

persist

public void persist(Object object)
             throws org.hibernate.HibernateException
Specified by:
persist in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

persist

public void persist(String entityName,
                    Object object)
             throws org.hibernate.HibernateException
Specified by:
persist in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

reconnect

@Deprecated
public void reconnect()
               throws org.hibernate.HibernateException
Deprecated. 

Specified by:
reconnect in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

reconnect

public void reconnect(Connection connection)
               throws org.hibernate.HibernateException
Specified by:
reconnect in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

refresh

@Deprecated
public void refresh(Object object,
                               org.hibernate.LockMode lockMode)
             throws org.hibernate.HibernateException
Deprecated. 

Specified by:
refresh in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

refresh

public void refresh(Object object,
                    org.hibernate.LockOptions lockOptions)
             throws org.hibernate.HibernateException
Specified by:
refresh in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

refresh

public void refresh(Object object)
             throws org.hibernate.HibernateException
Specified by:
refresh in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

replicate

public void replicate(Object object,
                      org.hibernate.ReplicationMode replicationMode)
               throws org.hibernate.HibernateException
Specified by:
replicate in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

replicate

public void replicate(String entityName,
                      Object object,
                      org.hibernate.ReplicationMode replicationMode)
               throws org.hibernate.HibernateException
Specified by:
replicate in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

save

public Serializable save(Object object)
                  throws org.hibernate.HibernateException
Specified by:
save in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

save

public Serializable save(String entityName,
                         Object object)
                  throws org.hibernate.HibernateException
Specified by:
save in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

saveOrUpdate

public void saveOrUpdate(Object object)
                  throws org.hibernate.HibernateException
Specified by:
saveOrUpdate in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

saveOrUpdate

public void saveOrUpdate(String entityName,
                         Object object)
                  throws org.hibernate.HibernateException
Specified by:
saveOrUpdate in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

setCacheMode

public void setCacheMode(org.hibernate.CacheMode cacheMode)
Specified by:
setCacheMode in interface org.hibernate.Session

setDefaultReadOnly

public void setDefaultReadOnly(boolean readOnly)
Specified by:
setDefaultReadOnly in interface org.hibernate.Session

setFlushMode

public void setFlushMode(org.hibernate.FlushMode flushMode)
Specified by:
setFlushMode in interface org.hibernate.Session

setReadOnly

public void setReadOnly(Object entityOrProxy,
                        boolean readOnly)
Specified by:
setReadOnly in interface org.hibernate.Session

update

public void update(Object object)
            throws org.hibernate.HibernateException
Specified by:
update in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

update

public void update(String entityName,
                   Object object)
            throws org.hibernate.HibernateException
Specified by:
update in interface org.hibernate.Session
Throws:
org.hibernate.HibernateException

2.17.2: 2011-06-17