[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4827?page=c...
]
Gergely K commented on HHH-4827:
--------------------------------
3.5.0-Beta-3 also has the same problem, except it generates a cross join:
... from ENTITY entity0_ cross join map map1_ cross join 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')
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
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira