persistence@glassfish.java.net

Question about input parameters for native queries

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Mon, 21 Aug 2006 22:51:54 +0200

Hi Linda, hi Mike,

there have been forum posts around input parameters for native queries.
Some of them use the Java Persistence Query syntax for positional
parameters: a question mark followed by a number, e.g. ?1. Is this
syntax supposed to be supported for native queries?

I assume I have to use the JDBC parameter syntax in native queries (a
question mark w/o number). Otherwise the persistence provider would need
to process the SQL query text before passing it to the JDBC layer.

The spec mentions input parameters for native queries in sections 3.6.3
and 3.6.6; e.g. it says: "Only positional parameter binding may be
portably used for native queries.". I understand this refers to method
Query.setParameter taking a position and not to the parameter syntax
used in the SQL query text, but others might read this different.

Regards Michael