[GLASSFISH-990] ? AND # SYMBOLS CAN'T BE USED IN NATIVE QUERY Created: 23/Aug/06  Updated: 06/Mar/12

Status: Open
Project: glassfish
Component/s: entity-persistence
Affects Version/s: 9.1pe
Fix Version/s: not determined

Type: Bug Priority: Minor
Reporter: ailitche Assignee: ailitche
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issuezilla Id: 990
Status Whiteboard:

HIGH


 Description   

Also logged as TopLink Also logged as TopLink bug 5472919.
? denotes positional parameter in native queries:
"select * from CMP3_ADDRESS where city=?"
or
"select * from CMP3_ADDRESS where city=?1"

However if ? are found in a literal - where it shouldn't be interpreted as a
parameter - the query fails:
"select * from CMP3_ADDRESS where city='?'"
The same with #:
"select * from CMP3_ADDRESS where city='#'".
? denotes positional parameter in native queries:
"select * from CMP3_ADDRESS where city=?"
or
"select * from CMP3_ADDRESS where city=?1"

However if ? are found in a literal - where it shouldn't be interpreted as a
parameter - the query fails:
"select * from CMP3_ADDRESS where city='?'"
The same with #:
"select * from CMP3_ADDRESS where city='#'"



 Comments   
Comment by pkrogh [ 08/Mar/07 ]

Reprioritized based on BUG triage. P4 HIGH.

Comment by gfbugbridge [ 29/Mar/07 ]

<BT6540683>

Comment by mb124283 [ 30/Mar/07 ]
      • Issue 2747 has been marked as a duplicate of this issue. ***
Comment by gyorke [ 07/Jan/08 ]

A simple work around is to convert the query to use a positional parameter and
provide the failing literal as a parameter.

Query query = em.createNativeQuery("select * from CMP3_ADDRESS where city=?1",
Address.class);
query.setParameter(1, "?");

Comment by Tom Mueller [ 06/Mar/12 ]

Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

Generated at Tue Feb 28 03:39:51 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.