On Dec 27, 2007, at 10:55 PM, Tore Halset wrote:
// new
<T> List<T> performQuery(Class<T> aClass, Query query);

+0. I would like to use a specific interface instead if possible.
public <T> List<T> performQuery(PersistentSelectQuery<T> query);

// new
List<DataRow> performDataRowQuery(Query query);

+0. I would like to use a specific interface instead if possible.
public List<DataRow> performQuery(DataRowQuery query);


Ok, I've played a bit with parameterizing Query... The results are mixed at best. I am trying to avoid the explosion of subclasses (consider that in addition to SelectQuery we have EJBQLQuery, ProcedureQuery, SQLTemplate, NamedQuery, ObjectIdQuery, etc. that can return a ResultSet). I think I solved the DataRowQuery subclass problem, by making it a decorator instead of a subclass:

public interface TypedQuery<T> extends Query {

}

public class DataRowQuery implements TypedQuery<org.apache.cayenne.DataRow> {

        protected Query query;

        public DataRowQuery(Query query) {
                this.query = query;
        }

        public SQLAction createSQLAction(SQLActionVisitor visitor) {
                return query.createSQLAction(visitor);
        }
        ...
}

But we are still left with 6 extra subclasses that the user will have to deal with in the code, as well as the method naming issues that Ari mentioned :-/

Andrus


Reply via email to