from
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
towards the end of the example there is
// select all customers in the same city
Customer criteria=new Customer();
criteria.setCity("New York");
Collection customersList =
custDAO.selectCustomersTO(criteria);
I reckon this is an excellent feature to be added.
i.e. fooDaoImplBase.getMatching(fooObj)
the select statement would look something like
sql = SQL_SELECT + WHERE 1=1
if( assertNotNull(fooObj.getFieldName()) {
sql += "AND field_name='"+fooObj.getFieldName()+"'";
if( assertNotNull(fooObj.getFieldName2()) {
sql += "AND field_name2='"+fooObj.getFieldName2()+"'";
etc!
This will allow to build the object fooObj with some
criteria and then fetch all of them from DB whithout
need to write the SQL