persistence@glassfish.java.net

Re: [Fwd: [Issue 990] New - ? AND # SYMBOLS CAN'T BE USED IN NATIVE QUERY]

From: Andrei Ilitchev <andrei.ilitchev_at_oracle.com>
Date: Wed, 23 Aug 2006 15:59:18 -0400

Yes, you are right.
----- Original Message -----
From: "Michael Bouschen" <Michael.Bouschen_at_Sun.COM>
To: <persistence_at_glassfish.dev.java.net>
Sent: Wednesday, August 23, 2006 3:39 PM
Subject: Re: [Fwd: [Issue 990] New - ? AND # SYMBOLS CAN'T BE USED IN NATIVE
QUERY]


> Hi Andrei,
>
> I would expect I have to call setParameter only once for the query Marina
> mentioned below:
> Query q = em.createNativeQuery("select * from ... where columnA=?1 or
> columnB=?1");
> q.setParameter(1, value);
> List result = query.getResultList();
>
> When using JDBC parameter syntax (just a question mark) I have to call
> setParameter twice:
> Query q = em.createNativeQuery("select * from ... where columnA=? or
> columnB=?");
> q.setParameter(1, value);
> q.setParameter(2, value);
> List result = query.getResultList();
>
> Am I right?
>
> Regards Michael
>> yes it does
>> ----- Original Message ----- From: "Marina Vatkina"
>> <Marina.Vatkina_at_Sun.COM>
>> To: "persistence" <persistence_at_glassfish.dev.java.net>
>> Sent: Wednesday, August 23, 2006 12:32 PM
>> Subject: [Fwd: [Issue 990] New - ? AND # SYMBOLS CAN'T BE USED IN NATIVE
>> QUERY]
>>
>>
>>> Andrei,
>>>
>>> Does TopLink support repeated parameters in native queries, e.g.
>>> "select * from ... where columnA=?1 or columnB=?1"
>>>
>>> thanks,
>>> -marina
>>>
>>> -------- Original Message --------
>>> From: ailitche_at_dev.java.net
>>> Subject: [Issue 990] New - ? AND # SYMBOLS CAN'T BE USED IN NATIVE QUERY
>>> To: issues_at_glassfish.dev.java.net
>>>
>>> https://glassfish.dev.java.net/issues/show_bug.cgi?id=990
>>> Issue #|990
>>> Summary|? AND # SYMBOLS CAN'T BE USED IN NATIVE QUERY
>>> Component|glassfish
>>> Version|9.1pe
>>> Platform|All
>>> OS/Version|All
>>> URL|
>>> Status|NEW
>>> Status whiteboard|
>>> Keywords|
>>> Resolution|
>>> Issue type|DEFECT
>>> Priority|P3
>>> Subcomponent|entity-persistence
>>> Assigned to|ailitche
>>> Reported by|ailitche
>>>
>>>
>>>
>>>
>>>
>>>
>>> ------- Additional comments from ailitche_at_dev.java.net Wed Aug 23
>>> 14:33:10 +0000 2006 -------
>>> 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='#'"
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: issues-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: issues-help_at_glassfish.dev.java.net
>>>
>>>
>