[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5539) ParameterParser does not support escaped ' symbols

Chris Morris (JIRA) noreply at atlassian.com
Fri Jan 14 07:09:05 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39630#action_39630 ] 

Chris Morris commented on HHH-5539:
-----------------------------------

No, there is a defect in the escaping of string values.

createSQLQuery(sql).list() fails to find a match, if the SQL is
   select screen.name as screenname from HOLD_ABSTRACTHOLDER as screen where screen.name = 'Hampton Additive + HT';
If I update the database to remove the "+" and change the query, the record is found.

I don't understand why Hibernate is processing this at all - the query works find in psql.

> ParameterParser does not support escaped ' symbols
> --------------------------------------------------
>
>                 Key: HHH-5539
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5539
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-sql
>    Affects Versions: 3.6.0.Beta4
>         Environment: 3.6.0 and postgresql 8.2.1
>            Reporter: Alexey Romanchuk
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> I create native SQLQuery with createSQLQuery method.
> Looks like ParameterParser incorrectly process queries with escaped ' symbol. For example query like "select * from a where a.b = 'asdf \' asdf'" works fine, but "select * from a where a.b = 'asdf \' asdf: '" fails with 
> org.hibernate.QueryException: Space is not allowed after parameter prefix ':' 'select * from a where a.b = 'asdf \' asdf''
> 	at org.hibernate.engine.query.ParameterParser.parse(ParameterParser.java:92)
> 	at org.hibernate.engine.query.ParamLocationRecognizer.parseLocations(ParamLocationRecognizer.java:75)
> 	at org.hibernate.engine.query.QueryPlanCache.buildNativeSQLParameterMetadata(QueryPlanCache.java:149)
> 	at org.hibernate.engine.query.QueryPlanCache.getSQLParameterMetadata(QueryPlanCache.java:79)
> 	at org.hibernate.impl.AbstractSessionImpl.createSQLQuery(AbstractSessionImpl.java:146)
> 	at org.hibernate.impl.SessionImpl.createSQLQuery(SessionImpl.java:1656)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list