[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4827) Incorrect SQL is generated when querying indexed scalar maps using 'or'

Gergely K (JIRA) noreply at atlassian.com
Thu Jan 21 09:26:29 EST 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gergely K updated HHH-4827:
---------------------------

    Attachment: hql-index-bug.zip

Updated test case

> Incorrect SQL is generated when querying indexed scalar maps using 'or'
> -----------------------------------------------------------------------
>
>                 Key: HHH-4827
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4827
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.3.2
>            Reporter: Gergely K
>            Priority: Critical
>         Attachments: hql-index-bug.zip, hql-index-bug.zip
>
>
> Querying indexed maps works fine with:
> from Entity e where e.map['aaa'] = 'foo'
> This generates the following (correct) SQL:
> select entity0_.ID as ID0_ from ENTITY entity0_, map map1_ 
> where entity0_.ID=map1_.ID and map1_.NAME = 'aaa' and map1_.VALUE='foo'
> However, an unexpected SQL is generated, when using an OR expression:
> from Entity e where ( map['aaa'] = 'foo' or map['bbb'] = 'bar')
> Generated SQL is:
> select entity0_.ID as ID0_ from ENTITY entity0_, map map1_, map map2_ where entity0_.ID=map1_.ID and map1_.NAME = 'aaa' and entity0_.ID=map2_.ID and map2_.NAME = 'bbb' and (map1_.VALUE='foo' or map2_.VALUE='bar')
> My problem is: the query returns no results when the map does not contain the key 'bbb', even if it does contain a key for 'aaa' (so the semantics of the HQL 'OR' are not translated correctly). Simply because the OR statement does not contain the "map2_.NAME = 'bbb'" part.
> (Moreover, the same map is joined twice, but this is only a performance issue.)
> Any workaround or suggestion is greatly appreciated.
> I've attached a simple test case for viewing the generated SQL (best viewed with eclipse + m2eclipse).

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