Re: Does 'like' work with parameterized expressions?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Nov 06 2004 - 13:45:25 EST

  • Next message: Todd O'Bryan: "Re: no datamap found???"

    Michael,

    Cayenne expressions do not support parameters embedded in char strings.
    Variable has to be a standalone node in the expression. See expression
    BNF document, "namedParameter" vs. "scalarCharExpression":

    http://objectstyle.org/cayenne/grammar/ExpressionParser.html

    Andrus

    On Nov 5, 2004, at 5:49 PM, Gentry, Michael wrote:

    > If you have something like:
    >
    > final Expression expression = Expression.fromString("referenceString
    > like '%$rs'");
    >
    > Map map = new HashMap(1);
    >
    > map.put("rs", "foo");
    >
    > SelectQuery query = new SelectQuery(My.class,
    > expression.expWithParameters(map));
    >
    >
    > Does the Expression class correctly parse the "like '%$rs'"? In my SQL
    > logging I see this as my binding:
    >
    > ... (t1.referenceString LIKE ?) ... [bind: '%$rs'] - prepared in 10 ms.
    >
    > Where I'd expect to see:
    >
    > ... (t1.referenceString LIKE ?) ... [bind: '%foo'] - prepared in 10 ms.
    >
    >
    > /dev/mrg
    >



    This archive was generated by hypermail 2.0.0 : Sat Nov 06 2004 - 13:45:29 EST