TechnoBuzz

A Techno Blog, mainly about Java

DAOs

DAOs (Data Access Objects) make use of the Template Method whereby there are several steps required, but you are only concern yourself with some of the steps. You encapsulate the individual steps we dont know how to perform as abstract methods, and provide an abstract superclass that invokes them .

I will have a Concrete subclasses of this abstract superclass implement the abstract methods to perform the individual steps.

For example, I have this method FindAllResources which returns a List which does a SQL Select operation.  All I have to be concerned with here is creating the select string and parameters and send it off to the SQL JDBC task.

List filterParms =

String statement ="SELECT …."

return this.findZeroOrMoreRecords(statement, filterParms.toArray());

I also have to copy what comes back from the database into a bean with the method:

Object processResultSetRow(ResultSetRow row)

June 20, 2005 Posted by | IoC | Leave a comment