October 24, 2003

Finders with arbitrary SQL

FireStorm/DAO 2.0 Standard Edition for JDBC now generates special finder methods for each table and view. This finder, known as the arbitrary SQL finder, has the following signature:

findByArbitrarySql(String sqlWhereClause, Object sqlParams[]);

Sample usage would be:

CustomerDao dao = CustomerDaoFactory.create();

Customer cust[] = dao.findByArbitrarySql(
"last_name = ?",
new Object[] { "Grove" }
);

Please note that this method should only be used where you need support for dynamic queries that are only known at runtime. If you need finders that use a fixed number of parameters and have a fixed SQL statement then you should define them as standard finders and generate specific code.

Posted by Andy Grove at October 24, 2003 11:55 AM