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