org.j2ee.dao
Class AbstractHibernateDAOAction

java.lang.Object
  |
  +--org.j2ee.dao.AbstractHibernateDAOAction
All Implemented Interfaces:
DAOAction, HibernateDAOAction
Direct Known Subclasses:
AbstractPageByPageAction

public abstract class AbstractHibernateDAOAction
extends java.lang.Object
implements HibernateDAOAction


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)

Field Summary
 
Fields inherited from interface org.j2ee.dao.HibernateDAOAction
DELETE, HQL_QUERY, LOAD, SAVE, SQL_QUERY, UPDATE
 
Constructor Summary
AbstractHibernateDAOAction()
          Default constructor, set HQL operation as default
AbstractHibernateDAOAction(int stmtTypeValue)
          Specialized constructor
 
Method Summary
 void execute(org.j2ee.dao.DAOActionProcessor processor)
          Execute this action using the given processor If there are exception, try to conver it with the Error Mapper and then call to Error Handler of this aciont
 java.lang.String getHQL()
          Implement this method if you are writting a HQL based Action
 java.lang.String[] getNamesForParams()
          This method retuns the names for parameters to be setted to sql/hql statement.
 java.lang.Object[] getParameters()
          This method retuns the parameters to be setted to SQL/HQL statement.
 java.lang.String[] getReturnAliasForSqlQuery()
          Alias used into the SQL query with the sintax {alias}
 java.lang.Class[] getReturnClassForSqlQuery()
          Hibernate requieres a class for every object returned by an SQL query
 java.lang.String getSQL()
          Implement this method if you are writting a SQL based Action
 int getStmtType()
          getter for private attribute
 java.lang.Object getTO()
          REDEFINE THIS METHOD ON EVERY SUBCLASS The transfer object used or setted by the action.
 void handleResult()
          Called by the Processor after an Hibernate succefull save,update,delete operation
 void handleResult(java.lang.Object to)
          Called by the Processor after an Hibernate succefull load operation
 void handleResults(java.util.List rs)
          Called by the Processor after an SQL or HQL succefull operation
 boolean isCaching()
           
 boolean isDelete()
          Returs true if this action is an DELETE statement
 boolean isHqlQuery()
          Returs true if this action is a HQL_QUERY statement
 boolean isLoad()
          Returs true if this action is an LOAD statement
 boolean isSave()
          Returs true if this action is an SAVE statement
 boolean isSqlQuery()
          Returs true if this action is a SQL_QUERY statement
 boolean isUpdate()
          Returs true if this action is an UPDATE statement
 void setCaching(boolean caching)
          Defines if the HQL or SQL query should be cached by the processor
 void setErrorHandler(org.j2ee.dao.DAOErrorHandler handler)
          This method allows to the action to set a class which manage application errors such as integrity constraint violated.
 void setStmtType(int stmtType)
          setter method for private attribute
 void setTO(java.lang.Object to)
          REDEFINE THIS METHOD ON EVERY SUBCLASS Set the private attribute, the transfer object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHibernateDAOAction

public AbstractHibernateDAOAction()
Default constructor, set HQL operation as default


AbstractHibernateDAOAction

public AbstractHibernateDAOAction(int stmtTypeValue)
Specialized constructor

Parameters:
stmtTypeValue - type of operation of this action
Method Detail

setTO

public void setTO(java.lang.Object to)
REDEFINE THIS METHOD ON EVERY SUBCLASS Set the private attribute, the transfer object. Concrete implementation of this interface must be properly implement this method to provide an uniform interface for all the actions.

Specified by:
setTO in interface DAOAction
Parameters:
to - (The Transfer Object used by the action)

getTO

public java.lang.Object getTO()
REDEFINE THIS METHOD ON EVERY SUBCLASS The transfer object used or setted by the action.

Specified by:
getTO in interface DAOAction
Returns:
the transfer object

setErrorHandler

public void setErrorHandler(org.j2ee.dao.DAOErrorHandler handler)
This method allows to the action to set a class which manage application errors such as integrity constraint violated.

Specified by:
setErrorHandler in interface DAOAction
Parameters:
handler - a instance with the application code to manage the exception
See Also:
interface for a list of the code passed to method

getSQL

public java.lang.String getSQL()
Implement this method if you are writting a SQL based Action

Specified by:
getSQL in interface HibernateDAOAction
Returns:
SQL string to be executed by the action

getHQL

public java.lang.String getHQL()
Implement this method if you are writting a HQL based Action

Specified by:
getHQL in interface HibernateDAOAction
Returns:
HQL String to be executed

getParameters

public java.lang.Object[] getParameters()
Description copied from interface: HibernateDAOAction
This method retuns the parameters to be setted to SQL/HQL statement.

Specified by:
getParameters in interface HibernateDAOAction
Returns:
an Object array with the parameters values for the HQL or SQL query

getNamesForParams

public java.lang.String[] getNamesForParams()
Description copied from interface: HibernateDAOAction
This method retuns the names for parameters to be setted to sql/hql statement. If this statement has not parameters, null can be returned.

Specified by:
getNamesForParams in interface HibernateDAOAction
Returns:
an String array with the names of the parameters declared into the HQL o SQL query

getReturnClassForSqlQuery

public java.lang.Class[] getReturnClassForSqlQuery()
Hibernate requieres a class for every object returned by an SQL query

Specified by:
getReturnClassForSqlQuery in interface HibernateDAOAction
Returns:
array of Class objects return by the SQL query

getReturnAliasForSqlQuery

public java.lang.String[] getReturnAliasForSqlQuery()
Alias used into the SQL query with the sintax {alias}

Specified by:
getReturnAliasForSqlQuery in interface HibernateDAOAction
Returns:
an array of alias used into the SQL query

getStmtType

public int getStmtType()
getter for private attribute

Specified by:
getStmtType in interface HibernateDAOAction
Returns:
stmtType

setStmtType

public void setStmtType(int stmtType)
setter method for private attribute

Specified by:
setStmtType in interface HibernateDAOAction
Parameters:
stmtType - value

isSqlQuery

public boolean isSqlQuery()
Description copied from interface: HibernateDAOAction
Returs true if this action is a SQL_QUERY statement

Specified by:
isSqlQuery in interface HibernateDAOAction
Returns:
true if the action is based on SQL query

isHqlQuery

public boolean isHqlQuery()
Description copied from interface: HibernateDAOAction
Returs true if this action is a HQL_QUERY statement

Specified by:
isHqlQuery in interface HibernateDAOAction
Returns:
true if the action is based on HQL query

isSave

public boolean isSave()
Description copied from interface: HibernateDAOAction
Returs true if this action is an SAVE statement

Specified by:
isSave in interface HibernateDAOAction
Returns:
true if the action is an Hibernate save operation

isUpdate

public boolean isUpdate()
Description copied from interface: HibernateDAOAction
Returs true if this action is an UPDATE statement

Specified by:
isUpdate in interface HibernateDAOAction
Returns:
true if the action is an Hibernate saveOrUpdate operation

isDelete

public boolean isDelete()
Description copied from interface: HibernateDAOAction
Returs true if this action is an DELETE statement

Specified by:
isDelete in interface HibernateDAOAction
Returns:
true if the action is an Hibernate save operation

isLoad

public boolean isLoad()
Description copied from interface: HibernateDAOAction
Returs true if this action is an LOAD statement

Specified by:
isLoad in interface HibernateDAOAction
Returns:
true if the action is an Hibernate load operation

handleResults

public void handleResults(java.util.List rs)
                   throws java.lang.Exception
Called by the Processor after an SQL or HQL succefull operation

Specified by:
handleResults in interface HibernateDAOAction
Parameters:
rs - List with the object results
Throws:
java.lang.Exception - generated by this method

handleResult

public void handleResult(java.lang.Object to)
                  throws java.lang.Exception
Called by the Processor after an Hibernate succefull load operation

Specified by:
handleResult in interface HibernateDAOAction
Parameters:
to - the object loaded
Throws:
java.lang.Exception

handleResult

public void handleResult()
                  throws java.lang.Exception
Called by the Processor after an Hibernate succefull save,update,delete operation

Specified by:
handleResult in interface HibernateDAOAction
Throws:
java.lang.Exception - generated by this method

execute

public void execute(org.j2ee.dao.DAOActionProcessor processor)
             throws DAOException
Execute this action using the given processor If there are exception, try to conver it with the Error Mapper and then call to Error Handler of this aciont

Specified by:
execute in interface DAOAction
Parameters:
processor - which will execute the action
Throws:
DAOException - generated by this method

isCaching

public boolean isCaching()
Specified by:
isCaching in interface HibernateDAOAction
Returns:
true if this HQL or SQL operation should be cached by the processor

setCaching

public void setCaching(boolean caching)
Defines if the HQL or SQL query should be cached by the processor

Specified by:
setCaching in interface HibernateDAOAction
Parameters:
caching -


Copyright © 2004 DAO Action Patterm. All Rights Reserved.