3.2.4: 2013-12-06

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, Session

public class SessionWrapper
extends AbstractQueryCache
implements 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
Session.LockRequest
 
Field Summary
private static long serialVersionUID
           
private  Session session
           
 
Constructor Summary
SessionWrapper(Session session)
          Creates a new session wrapper
 
Method Summary
 Transaction beginTransaction()
           
 Session.LockRequest buildLockRequest(LockOptions options)
           
 void cancelQuery()
           
 void clear()
           
 Connection close()
           
 Connection connection()
          Deprecated. 
 boolean contains(Object object)
           
 Criteria createCriteria(Class persistentClass)
           
 Criteria createCriteria(Class persistentClass, String alias)
           
 Criteria createCriteria(String entityName)
           
 Criteria createCriteria(String entityName, String alias)
           
 Query createFilter(Object collection, String queryString)
           
 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 object)
           
 void delete(String entityName, Object object)
           
 void disableFetchProfile(String name)
           
 void disableFilter(String filterName)
           
 Connection disconnect()
           
 void doWork(Work work)
           
 void enableFetchProfile(String name)
           
 Filter enableFilter(String filterName)
           
 void evict(Object object)
           
 void flush()
           
 Object get(Class clazz, Serializable id)
           
 Object get(Class clazz, Serializable id, LockMode lockMode)
          Deprecated. 
 Object get(Class clazz, Serializable id, LockOptions lockOptions)
           
 Object get(String entityName, Serializable id)
           
 Object get(String entityName, Serializable id, LockMode lockMode)
          Deprecated. 
 Object get(String entityName, Serializable id, LockOptions lockOptions)
           
 CacheMode getCacheMode()
           
 LockMode getCurrentLockMode(Object object)
           
 Filter getEnabledFilter(String filterName)
           
 EntityMode getEntityMode()
           
 String getEntityName(Object object)
           
 FlushMode getFlushMode()
           
 Serializable getIdentifier(Object object)
           
 LobHelper getLobHelper()
           
 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.
 Session getParentSession()
          Get the underlying parent session from Hibernate.
 Session getSession(EntityMode entityMode)
           
 SessionFactory getSessionFactory()
           
 SessionStatistics getStatistics()
           
 Transaction getTransaction()
           
 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, LockMode lockMode)
          Deprecated. 
 Object load(Class theClass, Serializable id, LockOptions lockOptions)
           
 void load(Object object, Serializable id)
           
 Object load(String entityName, Serializable id)
           
 Object load(String entityName, Serializable id, LockMode lockMode)
          Deprecated. 
 Object load(String entityName, Serializable id, LockOptions lockOptions)
           
 void lock(Object object, LockMode lockMode)
          Deprecated. 
 void lock(String entityName, Object object, 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, LockMode lockMode)
          Deprecated. 
 void refresh(Object object, LockOptions lockOptions)
           
 void replicate(Object object, ReplicationMode replicationMode)
           
 void replicate(String entityName, Object object, ReplicationMode replicationMode)
           
 Serializable save(Object object)
           
 Serializable save(String entityName, Object object)
           
 void saveOrUpdate(Object object)
           
 void saveOrUpdate(String entityName, Object object)
           
 void setCacheMode(CacheMode cacheMode)
           
 void setDefaultReadOnly(boolean readOnly)
           
 void setFlushMode(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 Session session
Constructor Detail

SessionWrapper

public SessionWrapper(Session session)
Creates a new session wrapper

Parameters:
session - The real Hibernate session
Method Detail

getParentSession

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


beginTransaction

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

buildLockRequest

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

cancelQuery

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

clear

public void clear()
Specified by:
clear in interface Session

close

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

connection

@Deprecated
public Connection connection()
                      throws HibernateException
Deprecated. 

Specified by:
connection in interface Session
Throws:
HibernateException

contains

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

createCriteria

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

createCriteria

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

createCriteria

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

createCriteria

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

createFilter

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

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

delete

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

delete

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

disableFetchProfile

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

disableFilter

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

disconnect

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

doWork

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

enableFetchProfile

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

enableFilter

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

evict

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

flush

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

get

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

Specified by:
get in interface Session
Throws:
HibernateException

get

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

get

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

get

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

Specified by:
get in interface Session
Throws:
HibernateException

get

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

get

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

getCacheMode

public CacheMode getCacheMode()
Specified by:
getCacheMode in interface Session

getCurrentLockMode

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

getEnabledFilter

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

getEntityMode

public EntityMode getEntityMode()
Specified by:
getEntityMode in interface Session

getEntityName

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

getFlushMode

public FlushMode getFlushMode()
Specified by:
getFlushMode in interface Session

getIdentifier

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

getLobHelper

public LobHelper getLobHelper()
Specified by:
getLobHelper in interface Session

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

getSession

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

getSessionFactory

public SessionFactory getSessionFactory()
Specified by:
getSessionFactory in interface Session

getStatistics

public SessionStatistics getStatistics()
Specified by:
getStatistics in interface Session

getTransaction

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

getTypeHelper

public TypeHelper getTypeHelper()
Specified by:
getTypeHelper in interface Session

isConnected

public boolean isConnected()
Specified by:
isConnected in interface Session

isDefaultReadOnly

public boolean isDefaultReadOnly()
Specified by:
isDefaultReadOnly in interface Session

isDirty

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

isFetchProfileEnabled

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

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Session

isReadOnly

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

load

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

Specified by:
load in interface Session
Throws:
HibernateException

load

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

load

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

load

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

load

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

Specified by:
load in interface Session
Throws:
HibernateException

load

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

load

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

lock

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

Specified by:
lock in interface Session
Throws:
HibernateException

lock

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

Specified by:
lock in interface Session
Throws:
HibernateException

merge

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

merge

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

persist

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

persist

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

reconnect

@Deprecated
public void reconnect()
               throws HibernateException
Deprecated. 

Specified by:
reconnect in interface Session
Throws:
HibernateException

reconnect

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

refresh

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

Specified by:
refresh in interface Session
Throws:
HibernateException

refresh

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

refresh

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

replicate

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

replicate

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

save

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

save

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

saveOrUpdate

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

saveOrUpdate

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

setCacheMode

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

setDefaultReadOnly

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

setFlushMode

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

setReadOnly

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

update

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

update

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

3.2.4: 2013-12-06