Re: NamedQuery parameters

From: Marcel (emmpeege..mail.com)
Date: Mon Jul 24 2006 - 11:17:19 EDT

  • Next message: Lothar Krenzien: "question about modeler"

    Ta (thanks, in case that's an Australian word) - that was my conclusion
    after some more investigation. I'll roll my own SelectQuery with
    expressions instead.

    Marcel

    Andrus Adamchik wrote:
    > Parameters are *arbitrary* "variables" that start with a "$" sign.
    > They do not have to match the attribute names. You would define them
    > in CayenneModeler for the query. For SelectQuery this would be the
    > part of the qualifier string, i.e. "loginid = $id" . In SQLTemplate
    > they are defined in the SQL (SELECT * FROM X WHERE T = $myP).
    >
    > Andrus
    >
    >
    > On Jul 24, 2006, at 10:46 AM, Marcel wrote:
    >
    >>
    >> Hi all,
    >>
    >> The following is from the wiki[1]:
    >>
    >> ---------------
    >> String[] keys = new String[] {"loginid", "password"};
    >> Object[] values = new String[] {"joe", "secret"};
    >>
    >> NamedQuery query = new NamedQuery("Login", keys, values);
    >>
    >> List matchingUsers = context.performQuery(query);
    >> ---------------
    >>
    >> I had presumed that this executes the query Login finding users where
    >> loginid = "joe" and password = "secret.
    >>
    >> Do the parameters need to be defined in the query beforehand? If so,
    >> how? If not, are they object attribute names or database attribute
    >> names?
    >>
    >> Cheers,
    >>
    >> Marcel
    >>
    >> [1] http://cwiki.apache.org/CAYDOC/namedquery.html
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Jul 24 2006 - 11:17:46 EDT