com.geekologue.md4j.dao
Class AbstractDAO

java.lang.Object
  extended by com.geekologue.md4j.dao.AbstractDAO
Direct Known Subclasses:
AbstractHbmDAO

public abstract class AbstractDAO
extends java.lang.Object

An abstract DAO class to be subclassed by other DAO implementations.

Author:
manos

Field Summary
protected  java.lang.Class daoClass
          The class object that the implementing subclass is responsible for its database operations.
protected  java.lang.String identifierName
           
 
Constructor Summary
protected AbstractDAO(java.lang.Class clazz, java.lang.String identifierName)
          Subclasses must call this constructor
 
Method Summary
abstract  void delete(java.io.Serializable identifier)
          Delete the object coresponding to the given identifier
abstract  java.lang.Object get(java.io.Serializable identifier)
          Retreive the object matching the class handled by this DAO and the given identifier or null if no match is found.
abstract  java.util.Set getBrokenUConstraints(java.util.Map params, java.io.Serializable id)
          Get unique constraint violations before persisting new objects
protected  java.lang.Object getDaoClassInstance()
          Get a new instance of the Class associated with this DAO (e.g.
abstract  Page getPage(java.util.Map params, Order order, int pageNumber, int pageSize)
          Get a page of results.
abstract  Page getPage(java.util.Set projectionProps, java.util.Map params, Order order, int pageNumber, int pageSize)
          Get a page of results.
abstract  java.util.Map getParentOptions()
          Get data to populate drop downs refering to parent objects by many-to-one relationships.
abstract  java.lang.Object load(java.io.Serializable identifier)
          Retreive the object matching the class handled by this DAO and the given identifier.
abstract  java.io.Serializable save(java.lang.Object pojo)
          Save the given object
abstract  void update(java.util.Map map)
          Update the object matching the given identifier according to the property value pairs in the given map.
abstract  void update(java.lang.Object pojo)
          Persist any changes to the given POJO
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

daoClass

protected java.lang.Class daoClass
The class object that the implementing subclass is responsible for its database operations. This variable must be set by all subclasses to the appropriate value.


identifierName

protected java.lang.String identifierName
Constructor Detail

AbstractDAO

protected AbstractDAO(java.lang.Class clazz,
                      java.lang.String identifierName)
Subclasses must call this constructor

Parameters:
clazz -
Method Detail

getDaoClassInstance

protected java.lang.Object getDaoClassInstance()
Get a new instance of the Class associated with this DAO (e.g. an instance of User for UserDAO)

Returns:

load

public abstract java.lang.Object load(java.io.Serializable identifier)
Retreive the object matching the class handled by this DAO and the given identifier. If the identifier is not match, an exception is thrown

Parameters:
identifier -
Returns:
the maching pojo
Throws:
DataAccessException

get

public abstract java.lang.Object get(java.io.Serializable identifier)
Retreive the object matching the class handled by this DAO and the given identifier or null if no match is found.

Parameters:
identifier -
Returns:
the maching pojo if any, null otherwise
Throws:
DataAccessException

update

public abstract void update(java.util.Map map)
Update the object matching the given identifier according to the property value pairs in the given map. If no match for the identifier is found, return null

Parameters:
map - the map with the property value pairs to update
Throws:
DataAccessException

update

public abstract void update(java.lang.Object pojo)
Persist any changes to the given POJO

Parameters:
pojo - the POJO to update
Throws:
DataAccessException

getPage

public abstract Page getPage(java.util.Set projectionProps,
                             java.util.Map params,
                             Order order,
                             int pageNumber,
                             int pageSize)
Get a page of results.

Parameters:
projectionProps - the names of the property values to return
params - the attribute-value pairs the results have to match
pageNumber - the number of the page
pageSize - the number of results in the page
Returns:
a result page containing the property values of the matching entities

getPage

public abstract Page getPage(java.util.Map params,
                             Order order,
                             int pageNumber,
                             int pageSize)
Get a page of results.

Parameters:
params - the attribute-value pairs the results have to match
pageNumber - the number of the page
pageSize - the number of results in the page
Returns:
a result page containing the matching entities

save

public abstract java.io.Serializable save(java.lang.Object pojo)
Save the given object

Parameters:
pojo - the POJO to save
Returns:
the saved pojo
Throws:
DataAccessException

delete

public abstract void delete(java.io.Serializable identifier)
Delete the object coresponding to the given identifier

Parameters:
pojo - the object to delete.
Throws:
DataAccessException

getBrokenUConstraints

public abstract java.util.Set getBrokenUConstraints(java.util.Map params,
                                                    java.io.Serializable id)
Get unique constraint violations before persisting new objects

Parameters:
params - the property value pairs to check
Returns:
a set of the broken property names

getParentOptions

public abstract java.util.Map getParentOptions()
Get data to populate drop downs refering to parent objects by many-to-one relationships.

Returns:
a Map where each key is the string name of the property for that parent object. The value for that key is yet another Map where the key value pair is used to the value and text (respectively) of HTML option elements


Copyright © 2003-2007 Manos Batsis. All Rights Reserved.