Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-563
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-563
Summary: Bad join in HQL queries
Type: Bug
Status: Unassigned
Priority: Major
Project: Hibernate2
Components:
core
Versions:
2.1
Assignee:
Reporter: William Drai
Created: Wed, 17 Dec 2003 8:08 AM
Updated: Wed, 17 Dec 2003 8:08 AM
Description:
I have the following (simplified) mapping :
<class name="Cat" table="CAT_T">
<id .. />
<many-to-one name="sex" class="Sex" column="sex_id" />
<many-to-one name="color" class="Color" column="color_id" />
</class>
<class name="Sex" table="SEX_T">
<id .. />
<property name="name" type="string" />
</class>
<class name="Color" table="COLOR_T">
<id .. />
<property name="name" type="string" />
</class>
The HQL query :
select cat
from cat in class Cat
where cat.sex.name = 'female'
or cat.color.name = 'black'
is translated to something like :
select cat
from CAT_T cat, SEX_T sex, COLOR_T color
where
(cat.sex_id = sex.id and sex.name = 'female')
or
(cat.color_id = color.id and color.name = 'black')
That means that I get a cartesian product of
all cats with sex female by all colors
and all cats with color black by all sexes.
That is a lot more results than the female or black cats.
What I expected was :
select cat
from CAT_T cat, SEX_T sex, COLOR_T color
where
cat.sex_id = sex.id
and cat.color_id = color.id
and (sex.name = 'female' or color.name = 'black')
I don't know whether this is really a bug or this is wanted for
some reason but it seems rather strange.
William
---------------------------------------------------------------------
JIRA INFORMATION:
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
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|