Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Issue with namedQuery/setParameter and string which contains "'" (single quote)

If it were an parameter it would be escaped, but from the JPQL it was just
inlined in the JPQL the user gave to the query.  You should use an argument
in the query, not inline parameters (in general, and ideally use a named
query).

i.e.
"select count(e) from Selection e  where e.owner = :owner and e.name = :name
and e.deleted = :deleted"



Tim Hollosy wrote:
> 
> Shouldn't that for sure be eascaped at the EclipseLink level? I've
> never used a library that supported parameters/binding that didn't
> escape everything, I thought that was half the point of parameters...
> 
> ./tch
> 
> 
> 
> On Mon, Sep 22, 2008 at 8:54 AM, Michael O'Brien
> <michael.obrien@xxxxxxxxxx> wrote:
>> Jan,
>>   It may be an unescaped single quote (') in the partial argument jan's. 
>> I get this sometimes across the web with my last name as well.  I'll
>> check if this should be escaped at the eclipselink or application level.
>>
>>   Thank you
>>   /michael
>>
>> ----------Original Message----------
>>
>> From: Jan Vissers <Jan.Vissers@xxxxxxxxxx>
>> Sent: Mon, September 22, 2008 8:49 AM
>> To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
>> Subject: [eclipselink-users] Issue with namedQuery/setParameter and
>> string which contains "'" (single quote)
>>
>>
>> I get the following error:
>>
>> Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services -
>> 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.JPQLException
>> Exception Description: Syntax error parsing the query [select count(e)
>> from Selection e  where e.owner = 'tangelo_admin' and e.name = 'Jan's
>> selectie' and e.deleted = false], line 1, column 84: syntax error at [s].
>> Internal Exception: MismatchedTokenException(66!=-1
>>
>> This must be a simple one right, what am I missing. I'm trying to query
>> records for which e.name = "Jan's selectie"
>>
>> Thanks,
>> -J.
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Issue-with-namedQuery-setParameter-and-string-which-contains-%22%27%22-%28single-quote%29-tp19606841p19608422.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top