org.nanocontainer.persistence.hibernate.classic
Class SessionDelegator

java.lang.Object
  extended by org.nanocontainer.persistence.hibernate.classic.SessionDelegator
All Implemented Interfaces:
Serializable, net.sf.hibernate.Session
Direct Known Subclasses:
FailoverSessionDelegator

public abstract class SessionDelegator
extends Object
implements net.sf.hibernate.Session

Abstract base class for session delegators, which delegates all calls to session obtained by implementing class. Also does error handling. All methods are just delegations to a Hibernate session.

Version:
$Version: $
Author:
Konstantin Pribluda, Jose Peleteiro
See Also:
Serialized Form

Constructor Summary
SessionDelegator()
           
SessionDelegator(HibernateExceptionHandler exceptionHandler)
           
 
Method Summary
 net.sf.hibernate.Transaction beginTransaction()
           
 void cancelQuery()
           
 void clear()
           
 Connection close()
           
 Connection connection()
           
 boolean contains(Object object)
           
 net.sf.hibernate.Criteria createCriteria(Class persistentClass)
           
 net.sf.hibernate.Query createFilter(Object collection, String queryString)
           
 net.sf.hibernate.Query createQuery(String queryString)
           
 net.sf.hibernate.Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses)
           
 net.sf.hibernate.Query createSQLQuery(String sql, String returnAlias, Class returnClass)
           
 void delete(Object object)
           
 int delete(String query)
           
 int delete(String query, Object[] values, net.sf.hibernate.type.Type[] types)
           
 int delete(String query, Object value, net.sf.hibernate.type.Type type)
           
 Connection disconnect()
           
 void evict(Object object)
           
 Collection filter(Object collection, String filter)
           
 Collection filter(Object collection, String filter, Object[] values, net.sf.hibernate.type.Type[] types)
           
 Collection filter(Object collection, String filter, Object value, net.sf.hibernate.type.Type type)
           
 List find(String query)
           
 List find(String query, Object[] values, net.sf.hibernate.type.Type[] types)
           
 List find(String query, Object value, net.sf.hibernate.type.Type type)
           
 void flush()
           
 Object get(Class clazz, Serializable id)
           
 Object get(Class clazz, Serializable id, net.sf.hibernate.LockMode lockMode)
           
 net.sf.hibernate.LockMode getCurrentLockMode(Object object)
           
protected abstract  net.sf.hibernate.Session getDelegatedSession()
          obtain hibernate session.
 net.sf.hibernate.FlushMode getFlushMode()
           
 Serializable getIdentifier(Object object)
           
 net.sf.hibernate.Query getNamedQuery(String queryName)
           
 net.sf.hibernate.SessionFactory getSessionFactory()
           
protected  RuntimeException handleException(net.sf.hibernate.HibernateException cause)
          Invalidates the session calling invalidateDelegatedSession() and convert the cause using a ExceptionHandler if it's available otherwise throws the cause back.
protected  RuntimeException handleException(RuntimeException cause)
          Invalidates the session calling invalidateDelegatedSession() and convert the cause using a ExceptionHandler if it's available otherwise just return the cause back.
protected abstract  void invalidateDelegatedSession()
          perform actions to dispose "burned" session properly
 boolean isConnected()
           
 boolean isDirty()
           
 boolean isOpen()
           
 Iterator iterate(String query)
           
 Iterator iterate(String query, Object[] values, net.sf.hibernate.type.Type[] types)
           
 Iterator iterate(String query, Object value, net.sf.hibernate.type.Type type)
           
 Object load(Class theClass, Serializable id)
           
 Object load(Class theClass, Serializable id, net.sf.hibernate.LockMode lockMode)
           
 void load(Object object, Serializable id)
           
 void lock(Object object, net.sf.hibernate.LockMode lockMode)
           
 void reconnect()
           
 void reconnect(Connection connection)
           
 void refresh(Object object)
           
 void refresh(Object object, net.sf.hibernate.LockMode lockMode)
           
 void replicate(Object object, net.sf.hibernate.ReplicationMode replicationMode)
           
 Serializable save(Object object)
           
 void save(Object object, Serializable id)
           
 void saveOrUpdate(Object object)
           
 Object saveOrUpdateCopy(Object object)
           
 Object saveOrUpdateCopy(Object object, Serializable id)
           
 void setFlushMode(net.sf.hibernate.FlushMode flushMode)
           
 void update(Object object)
           
 void update(Object object, Serializable id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionDelegator

public SessionDelegator()

SessionDelegator

public SessionDelegator(HibernateExceptionHandler exceptionHandler)
Parameters:
exceptionHandler - Exception handler component to use with created session
Method Detail

getDelegatedSession

protected abstract net.sf.hibernate.Session getDelegatedSession()
obtain hibernate session.


invalidateDelegatedSession

protected abstract void invalidateDelegatedSession()
                                            throws net.sf.hibernate.HibernateException
perform actions to dispose "burned" session properly

Throws:
net.sf.hibernate.HibernateException

handleException

protected RuntimeException handleException(net.sf.hibernate.HibernateException cause)
                                    throws net.sf.hibernate.HibernateException
Invalidates the session calling invalidateDelegatedSession() and convert the cause using a ExceptionHandler if it's available otherwise throws the cause back.

Throws:
net.sf.hibernate.HibernateException

handleException

protected RuntimeException handleException(RuntimeException cause)
Invalidates the session calling invalidateDelegatedSession() and convert the cause using a ExceptionHandler if it's available otherwise just return the cause back.


flush

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

setFlushMode

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

getFlushMode

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

getSessionFactory

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

connection

public Connection connection()
                      throws net.sf.hibernate.HibernateException
Specified by:
connection in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

disconnect

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

reconnect

public void reconnect()
               throws net.sf.hibernate.HibernateException
Specified by:
reconnect in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

reconnect

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

close

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

cancelQuery

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

isOpen

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

isConnected

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

isDirty

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

getIdentifier

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

contains

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

evict

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

load

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

load

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

load

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

replicate

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

save

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

save

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

saveOrUpdate

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

update

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

update

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

saveOrUpdateCopy

public Object saveOrUpdateCopy(Object object)
                        throws net.sf.hibernate.HibernateException
Specified by:
saveOrUpdateCopy in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

saveOrUpdateCopy

public Object saveOrUpdateCopy(Object object,
                               Serializable id)
                        throws net.sf.hibernate.HibernateException
Specified by:
saveOrUpdateCopy in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

delete

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

find

public List find(String query)
          throws net.sf.hibernate.HibernateException
Specified by:
find in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

find

public List find(String query,
                 Object value,
                 net.sf.hibernate.type.Type type)
          throws net.sf.hibernate.HibernateException
Specified by:
find in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

find

public List find(String query,
                 Object[] values,
                 net.sf.hibernate.type.Type[] types)
          throws net.sf.hibernate.HibernateException
Specified by:
find in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

iterate

public Iterator iterate(String query)
                 throws net.sf.hibernate.HibernateException
Specified by:
iterate in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

iterate

public Iterator iterate(String query,
                        Object value,
                        net.sf.hibernate.type.Type type)
                 throws net.sf.hibernate.HibernateException
Specified by:
iterate in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

iterate

public Iterator iterate(String query,
                        Object[] values,
                        net.sf.hibernate.type.Type[] types)
                 throws net.sf.hibernate.HibernateException
Specified by:
iterate in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

filter

public Collection filter(Object collection,
                         String filter)
                  throws net.sf.hibernate.HibernateException
Specified by:
filter in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

filter

public Collection filter(Object collection,
                         String filter,
                         Object value,
                         net.sf.hibernate.type.Type type)
                  throws net.sf.hibernate.HibernateException
Specified by:
filter in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

filter

public Collection filter(Object collection,
                         String filter,
                         Object[] values,
                         net.sf.hibernate.type.Type[] types)
                  throws net.sf.hibernate.HibernateException
Specified by:
filter in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

delete

public int delete(String query)
           throws net.sf.hibernate.HibernateException
Specified by:
delete in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

delete

public int delete(String query,
                  Object value,
                  net.sf.hibernate.type.Type type)
           throws net.sf.hibernate.HibernateException
Specified by:
delete in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

delete

public int delete(String query,
                  Object[] values,
                  net.sf.hibernate.type.Type[] types)
           throws net.sf.hibernate.HibernateException
Specified by:
delete in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

lock

public void lock(Object object,
                 net.sf.hibernate.LockMode lockMode)
          throws net.sf.hibernate.HibernateException
Specified by:
lock in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

refresh

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

refresh

public void refresh(Object object,
                    net.sf.hibernate.LockMode lockMode)
             throws net.sf.hibernate.HibernateException
Specified by:
refresh in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

getCurrentLockMode

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

beginTransaction

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

createCriteria

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

createQuery

public net.sf.hibernate.Query createQuery(String queryString)
                                   throws net.sf.hibernate.HibernateException
Specified by:
createQuery in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

createFilter

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

getNamedQuery

public net.sf.hibernate.Query getNamedQuery(String queryName)
                                     throws net.sf.hibernate.HibernateException
Specified by:
getNamedQuery in interface net.sf.hibernate.Session
Throws:
net.sf.hibernate.HibernateException

createSQLQuery

public net.sf.hibernate.Query createSQLQuery(String sql,
                                             String returnAlias,
                                             Class returnClass)
Specified by:
createSQLQuery in interface net.sf.hibernate.Session

createSQLQuery

public net.sf.hibernate.Query createSQLQuery(String sql,
                                             String[] returnAliases,
                                             Class[] returnClasses)
Specified by:
createSQLQuery in interface net.sf.hibernate.Session

clear

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

get

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

get

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


Copyright 2003-2003-2006 Codehaus. All Rights Reserved.