[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3785) HQL parser not throwing error for unmatched parantheses

Gail Badner (JIRA) noreply at atlassian.com
Wed Feb 25 18:22:43 EST 2009


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

Gail Badner commented on HHH-3785:
----------------------------------

Please attach a runnable (Java + mapping) test case that reproduces this issue.

> HQL parser not throwing error for unmatched parantheses
> -------------------------------------------------------
>
>                 Key: HHH-3785
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3785
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.2.6
>         Environment: Hibernate 3.2.6, Sybase ASE 12, Windows XP SP2
>            Reporter: Amaresh wakkar
>
> I have following query which I would have expected HQL parser to throw QuerySyntaxException:unexpected token.
> ================================
> from WebAuditLog wal  where wal.tmstampLastModified >= convert(date, '18-FEB-09', 111)  
> and wal.tmstampLastModified <= convert(date, '18-FEB-09', 111)) 
> and wal.sourceId = 'I'  
> order by wal.client.clientId, wal.tmstampLastModified
> ====================================
> The problem with this query is that on Line#2, there is a redundant unmatched right parantheses i.e. ')' . Ideally this should have been reported as Query syntax exception by HQL parser. Unfortunately, what HQL parses does is 
> 1. ignores everything beyond that errorneous right parantheses
> 2. Executes such terminated query and returns results which gives impression to user that query is syntactically valid and errors must be either with data or logic of query.
> Workaround:
> In absensce of HQL parses throwing error, we must ensure that the HQL is correctly written by reviewing it carefully.
> Steps to replicate:
> 1.Create any table which has 2 or 3 columns
> 2. Try writing a HQL which uses parantheses e.g. functions like convert etc. Add an extra right parantheses at the end of such function's closing right parantheses
> 3. add additional where clause filtering criteria after step-2
> 4. Execute the query.
> 5. In the result you would notice that the where clause criteria mentioned in step-3 is ignored and query is executed as if the query terminated at step-2
> I have done a quick search through existing bugs but couldn't find any matching right away so reporting it here.
> Hope it helps to make Hibernate HQL parser even more robust
> Thanks and regards,
> Amaresh Wakkar

-- 
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