[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2647) Problems with OR parenthesis in HQL

ivan wang (JIRA) noreply at atlassian.com
Wed Oct 24 04:33:39 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28529 ] 

ivan wang commented on HHH-2647:
--------------------------------

Dear all,

I think I encountered the same problem. Will there be a fix for this ? or is there any workaround ?

HQL query :

select o from VwPubQaAnswer o
where articleId <> :articleId 
and parentArticleId is null 
and ((repliedDate < :repliedDate) or (repliedDate = :repliedDate and articleId < :articleId )) 
order by repliedDate desc, articleId desc

SQL generated:

select vwpubqaans0_.QA_ID as QA1_1652_, vwpubqaans0_.ANSWER as ANSWER1652_, vwpubqaans0_.ARTICLE_ID as ARTICLE3_1652_, vwpubqaans0_.CREATED_DATE as CREATED4_1652_, vwpubqaans0_.PARENT_ARTICLE_ID as PARENT5_1652_, vwpubqaans0_.QUESTION as QUESTION1652_, vwpubqaans0_.REPLIED_DATE as REPLIED7_1652_, vwpubqaans0_.REPLIED_DISPLAY_NAME as REPLIED8_1652_, vwpubqaans0_.SENDER_NICKNAME as SENDER9_1652_ 
from QUAM_ADM.VW_PUB_QA_ANSWER vwpubqaans0_ 
where 
vwpubqaans0_.ARTICLE_ID<>? 
and (vwpubqaans0_.PARENT_ARTICLE_ID is null) 
and (vwpubqaans0_.REPLIED_DATE<? or vwpubqaans0_.REPLIED_DATE=? and vwpubqaans0_.ARTICLE_ID<?) 
order by vwpubqaans0_.REPLIED_DATE desc, vwpubqaans0_.ARTICLE_ID desc

Thanks.

> Problems with OR parenthesis in HQL
> -----------------------------------
>
>                 Key: HHH-2647
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2647
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.2.1
>         Environment: Hibernate 3.2.1, postgresql 8.2, jboss 5 embedded beta 2
>            Reporter: Dennis Fleurbaaij
>   Original Estimate: 15 minutes
>  Remaining Estimate: 15 minutes
>
> Given the following (part) of a query in HQL (where 1 to 6 are comparisons of different types (=, <=, is null), but irrelevant for the problem posted here ):
> AND ( ( 1 AND 2 ) OR ( 3 AND 4 )  OR ( 5 AND 6 ) )
> will be balanced to:
> and ( ( 1 ) and 2 or 3 and ( 4 ) or 5 and 6 )

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