Re: Expressions and arbitrary SQL?

From: Mike Kienenberger (mkienen..laska.net)
Date: Sun Jan 18 2004 - 13:02:10 EST

  • Next message: Jim Menard: "Re: Expressions and arbitrary SQL?"

    Jim Menard <jim..o.com> wrote:
    > String sql = "select * from photo where my_generated_clause";
    > Photo photo = (Photo)context.objectFromDataRow("Photo",
    > context.performQuery(sql);

    I do something similar, allowing users to construct SQL statements from a
    popup list of field names, a popup list of operators, and a value text field
    on a variety of tables.

    However, I build a SelectQuery object from a List of Expressions rather than
    an SQL string.

    I use code like this (snippets cut from my generic ReportComponent object:

           List qualifierList = new ArrayList();
    [...]
                                                                    qualifier = ExpressionFactory.greaterOrEqualExp(attributeString,
    aNumber);
    [...]
                    qualifierList.add(qualifier);
    [...]
                    Expression andedQualifiers = ExpressionFactory.joinExp(Expression.AND,
    qualifierList);
                    SelectQuery query = new SelectQuery(entity, andedQualifiers);
                    reportRowsList = dataContext.performQuery(aSelectQuery);



    This archive was generated by hypermail 2.0.0 : Sun Jan 18 2004 - 13:01:42 EST