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

Paizo (JIRA) noreply at atlassian.com
Tue Feb 1 07:11:05 EST 2011


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

Paizo commented on HHH-2647:
----------------------------

No, it's not consistent.
Example:

HQL:
from d.defects.def8715.lim.bl.pom.impl.PContainer p where ( p.i = ?) and ( ( p.entityId .class$ <> ?) or ( p.entityId .ser$ <> ?)) and ( p.i = ?)

SQL (omitting select and from for readability):
where pcontainer0_.c_i_818c4=? and pcontainer0_.class$_entit_1f106<>? or pcontainer0_.ser$_entityI_1f106<>? and pcontainer0_.c_i_818c4=?

This is an awesome bug :D i tried to workaround this problem http://opensource.atlassian.com/projects/hibernate/browse/HHH-5886 explicity using component's field.
So it seems that the workaround of the workaround is to convert the 'or' using 'NOT'

> Problems with OR parenthesis in HQL
> -----------------------------------
>
>                 Key: HHH-2647
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2647
>             Project: Hibernate Core
>          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
>            Assignee: Steve Ebersole
>         Attachments: testcase.zip
>
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> 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