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

Guillaume Jeudy (JIRA) noreply at atlassian.com
Thu Oct 9 15:25:05 EDT 2008


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

Guillaume Jeudy commented on HHH-2647:
--------------------------------------

I'm getting the same problem with the following and Nicolas's workaround to use NOT(not(3 and 4) and not(5 and 6) doesnt work.
Here's the HQL produced and the SQL results:

HQL:  from SymbolMappingImpl e 
where (e.businessKey.subBusinessDivisionCdId = 5412 and e.businessKey.productFamilyCdId = 4540 and e.businessKey.symbolCdId = 5969 and e.businessKey.companyCdId = 3802 and e.businessKey.stateCdId = 3744) or 
(e.businessKey.subBusinessDivisionCdId = 5412 and e.businessKey.productFamilyCdId = 4540 and e.businessKey.symbolCdId = 5969 
and e.businessKey.companyCdId = 3802 and e.businessKey.stateCdId = 3744) 

SQL: select symbolmapp0_.SymbolMappingId as SymbolMa1_217_, symbolmapp0_.SubBusinessDivisionCdId as SubBusin2_217_, 
symbolmapp0_.ProductFamilyCdId as ProductF3_217_, symbolmapp0_.SymbolCdId as SymbolCdId217_, 
symbolmapp0_.CompanyCdId as CompanyC5_217_, symbolmapp0_.StateCdId as StateCdId217_, symbolmapp0_.EffectiveDt as Effectiv7_217_, 
symbolmapp0_.ExpirationDt as Expirati8_217_ 
from SymbolMapping symbolmapp0_ 
where symbolmapp0_.SubBusinessDivisionCdId=5412 and symbolmapp0_.ProductFamilyCdId=4540 and symbolmapp0_.SymbolCdId=5969 and
symbolmapp0_.CompanyCdId=3802 and symbolmapp0_.StateCdId=3744 or 
symbolmapp0_.SubBusinessDivisionCdId=5412 and symbolmapp0_.ProductFamilyCdId=4540 and symbolmapp0_.SymbolCdId=5969 and 
symbolmapp0_.CompanyCdId=3802 and symbolmapp0_.StateCdId=3744 

I attached XML and java file. I have to fallback to raw SQL query to solve that one....

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