org.j2ee.dao
Class DAOHibernateActionProcessorImpl

java.lang.Object
  |
  +--org.j2ee.dao.DAOHibernateActionProcessorImpl
All Implemented Interfaces:
DAOActionProcessor

public class DAOHibernateActionProcessorImpl
extends java.lang.Object
implements DAOActionProcessor


Based on an example of book Code Notes for J2EE, Edited by GREGORY BRILL, e-ISBN 0-679-64727-9
Last modified $Date: 2004/05/18 10:50:12 $

Version:
$Revision: 1.1.1.1 $
Author:
mochoa (mochoa@users.sourceforge.net)

Constructor Summary
DAOHibernateActionProcessorImpl()
           
 
Method Summary
 void addClass(java.lang.Class clazz)
          A wrapped method for Hibernate addClass(Class persistenClass) but without throwing the MappingException.
 void beginTransaction()
          Start a new Hibernate transaction.
 void closeSession()
          close a started session
 void commitTransaction()
          commit a started transaction.
static net.sf.hibernate.cfg.Configuration getConfiguration()
           
 java.sql.Connection getConnection()
          Provides the JDBC connection object stored into the private instance
 org.j2ee.dao.errors.ErrorMapper getErrorMapper()
          Return an ErrorMapper object to translate SQLException or other kind of exception to a common error list code
 void getSession()
          get/start an Hibernate Session object to be used for external controled action.
static net.sf.hibernate.SessionFactory getSessionFactory()
           
 void process(org.j2ee.dao.DAOAction acmd)
          execute a command action.
 void rollbackTransaction()
          rollback a started transaction.
 void setConnection(java.sql.Connection connection)
          Provide an external JDBC Connection to be used by Hibernate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DAOHibernateActionProcessorImpl

public DAOHibernateActionProcessorImpl()
Method Detail

getConfiguration

public static net.sf.hibernate.cfg.Configuration getConfiguration()
                                                           throws net.sf.hibernate.HibernateException
net.sf.hibernate.HibernateException

getSessionFactory

public static net.sf.hibernate.SessionFactory getSessionFactory()
                                                         throws net.sf.hibernate.HibernateException
net.sf.hibernate.HibernateException

addClass

public void addClass(java.lang.Class clazz)
A wrapped method for Hibernate addClass(Class persistenClass) but without throwing the MappingException.

Parameters:
clazz -

getErrorMapper

public org.j2ee.dao.errors.ErrorMapper getErrorMapper()
Return an ErrorMapper object to translate SQLException or other kind of exception to a common error list code

Specified by:
getErrorMapper in interface DAOActionProcessor
Returns:
ErrorMapper

getConnection

public java.sql.Connection getConnection()
Provides the JDBC connection object stored into the private instance

Specified by:
getConnection in interface DAOActionProcessor
Returns:
a JDBC connection

setConnection

public void setConnection(java.sql.Connection connection)
Provide an external JDBC Connection to be used by Hibernate

Specified by:
setConnection in interface DAOActionProcessor
Parameters:
connection -

getSession

public void getSession()
                throws DAOException
get/start an Hibernate Session object to be used for external controled action.

Specified by:
getSession in interface DAOActionProcessor
Throws:
net.sf.hibernate.HibernateException - if there are errors open the session
DAOException - if there are errors open the session

beginTransaction

public void beginTransaction()
                      throws DAOException
Start a new Hibernate transaction. This method is usefull when you need to manage Macro Actions. The first action takes the session and the transaction a pass it to the others. For example.

Specified by:
beginTransaction in interface DAOActionProcessor
Throws:
net.sf.hibernate.HibernateException
DAOException

commitTransaction

public void commitTransaction()
                       throws DAOException
commit a started transaction.

Specified by:
commitTransaction in interface DAOActionProcessor
Throws:
net.sf.hibernate.HibernateException
DAOException

rollbackTransaction

public void rollbackTransaction()
                         throws DAOException
rollback a started transaction.

Specified by:
rollbackTransaction in interface DAOActionProcessor
Throws:
net.sf.hibernate.HibernateException
DAOException

closeSession

public void closeSession()
                  throws DAOException
close a started session

Specified by:
closeSession in interface DAOActionProcessor
Throws:
net.sf.hibernate.HibernateException
DAOException

process

public void process(org.j2ee.dao.DAOAction acmd)
             throws DAOException
execute a command action. If the session/transaction is already started use them. if not, open a session/transaction and close them immediatelly.

Specified by:
process in interface DAOActionProcessor
Parameters:
acmd -
Throws:
DAOException


Copyright © 2004 DAO Action Patterm. All Rights Reserved.