David mentioned recently that the delegator has quite a number of
methods in it; this can be daunting to new users.

If it could handle sql natively, then this could be reduced.

EntityCondition condition = new EntityConditionList(
        UtilMisc.toList(
                new EntityExpr("firstName", EntityOperator.LIKE, "%Adam%"),
                new EntityExpr("lastName", EntityOperator.LIKE, "%Heath%")
        ),
        EntityOperator.AND
);
List people = delegator.findByConditionCache("Person", condition, null,
UtilMisc.toList("firstName", "lastName"));

... or ....

Query query = delegator.compileSql("SELECT * FROM Person WHERE firstName
LIKE $firstName AND lastName LIKE $lastName ORDER BY firstName, lastName");
query.setParameter("firstName", "%Adam%");
query.setParameter("lastName", "%Heath%");
List people = delegator.runQuery(query);

The compiled query could be cached, or created during an init phase;
this would speed things up.  Additionally, views could also be done with
this sql code.  And the sql string could be generated by a template;
meaning that whole parts of it might be conditional, using
freemarker/velocity conditions, both on joins, and regular group
by/order by/select fields/conditions.

Reply via email to