net.sf.borg9.persistence.access
Class DataAccessObject

java.lang.Object
  extended by net.sf.borg9.persistence.access.DataAccessObject

public abstract class DataAccessObject
extends java.lang.Object

this super-class has convenience methods that hibernate DAOs typically would need. some of the functionality includes:


Constructor Summary
DataAccessObject()
           
 
Method Summary
protected static void addEq(java.lang.String aColumn, java.lang.Object aValue, Criteria aCriteria)
          adds
protected static void addLike(java.lang.String aColumn, java.lang.String aValue, Criteria aCriteria)
          adds
protected static void delete(DataTransferObject aQbeDto, Session aSession)
          handles deletes, handles the transaction commital, etc...
protected static java.util.List find(DataTransferObject aQbeDto, Criteria aCriteria, Session aSession)
          generic find method
protected static Session getSession(java.lang.Class aClass)
          get a hibernate session for the given class type
protected static java.util.List handleFindAllResults(java.util.List aList)
          this ensures that we have a consistent policy regarding findAll methods.
protected static java.util.List handleFindAllResults(java.util.List aList, int aMaxRows)
          this ensures that we have a consistent policy regarding findAll methods.
protected static DataTransferObject handleFindOneResults(java.util.List aList)
          this ensures that we have a consistent policy regarding findOne methods.
static DataTransferObject store(DataTransferObject aDto, java.lang.Class aClass)
          a generic store method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataAccessObject

public DataAccessObject()
Method Detail

store

public static DataTransferObject store(DataTransferObject aDto,
                                       java.lang.Class aClass)
                                throws DataAccessException
a generic store method.

Throws:
DataAccessException

find

protected static java.util.List find(DataTransferObject aQbeDto,
                                     Criteria aCriteria,
                                     Session aSession)
                              throws DataAccessException
generic find method

Throws:
DataAccessException

delete

protected static void delete(DataTransferObject aQbeDto,
                             Session aSession)
                      throws DataAccessException
handles deletes, handles the transaction commital, etc...

Throws:
DataAccessException

addLike

protected static void addLike(java.lang.String aColumn,
                              java.lang.String aValue,
                              Criteria aCriteria)
adds
and column like 'value%'
to the criteria. this is case sensitive.


addEq

protected static void addEq(java.lang.String aColumn,
                            java.lang.Object aValue,
                            Criteria aCriteria)
adds
and column = 'value'
to the criteria. this is case sensitive.


handleFindOneResults

protected static DataTransferObject handleFindOneResults(java.util.List aList)
                                                  throws DataAccessException
this ensures that we have a consistent policy regarding findOne methods. a case could be argued that getting 0 results from a findOne shouldn't be an exceptional situation but if we don't throw an exception in all cases where the results don't equal 1, the api user will be checking for nulls as well as catching exceptions. you have to down-cast to your particular DTO since this method just returns DataTransferObject.

Throws:
DataAccessException

handleFindAllResults

protected static java.util.List handleFindAllResults(java.util.List aList)
                                              throws TooManyResultsException
this ensures that we have a consistent policy regarding findAll methods. this method uses the default value. this value is not guaranteed to be anything in particular.

Throws:
TooManyResultsException

handleFindAllResults

protected static java.util.List handleFindAllResults(java.util.List aList,
                                                     int aMaxRows)
                                              throws TooManyResultsException
this ensures that we have a consistent policy regarding findAll methods.

Throws:
TooManyResultsException

getSession

protected static Session getSession(java.lang.Class aClass)
                             throws DataAccessException
get a hibernate session for the given class type

Throws:
DataAccessException