Re: Named Queries with parameters on SQLServer

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jul 20 2007 - 14:47:22 EDT

  • Next message: Andrus Adamchik: "Re: On the fly reengineering of database schema"

    On Jul 20, 2007, at 2:25 PM, Thomas Gilbert wrote:

    > Dear All,
    >
    > Do you have any hints about NamedQueries with parameters on
    > SQLServer ?
    > I created a named query "Q1", let's say "select * from T where x = ?".
    > How can I pass the parameter value to this query as it can only be
    > done via key/value pairs, and on SQLServer, parameters are not
    > name... ?
    >
    > Thanks a lot
    >
    > Thomas

    Hi Thomas,

    I assume your named query is mapped in the modeler as raw SQL?? If
    that's the case, named parameters are mapped using Cayenne format,
    that has nothing to do with syntax of the PreparedStatement (that it
    will will eventually generate). So your query SQL would look like this:

    "select * from T where x = $myParameter"

    so later you can use "myParameter" as a key name. You can read more
    here:

       http://cayenne.apache.org/doc20/scripting-sqltemplate.html

    Again - $ variables is a Cayenne artifact, that is not related to
    JDBC or the underlying DB.

    Andrus



    This archive was generated by hypermail 2.0.0 : Fri Jul 20 2007 - 14:47:49 EDT