Issue Type: Bug Bug
Affects Versions: 4.1.4
Assignee: Unassigned
Components: core, query-hql, query-sql
Created: 19/Jun/12 12:49 PM
Description:

From NHibernate's JIRA: https://nhibernate.jira.com/browse/NH-3057

The mapping:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.NH3057">

<class name="BaseClass" table="baseclass">
<id name="Id" column="id">
<generator class="assigned" />
</id>
<property name="InheritedProperty" column="inheritedproperty" />

<joined-subclass name="BClass" table="bclass">
<key column="id" />
<many-to-one name="A" column="aid" class="AClass" />
</joined-subclass>
</class>

<class name="AClass" table="aclass">
<id name="Id" column="id" generator="assigned" />
<set name="Bs" inverse="true" lazy="true">
<key column="aid" />
<one-to-many class="BClass" />
</set>
</class>
</hibernate-mapping>

The query:

from AClass a where exists (from a.Bs b where b.InheritedProperty = 'B2')

Generates following sql:

select
aclass0_.id as id2_
from
aclass aclass0_
where
exists (
select
bs1_.id
from
bclass bs1_ – there is missed inner join with base class
where
aclass0_.id=bs1_.aid
and bs1_1_.inheritedproperty='B2'
)

All examples are from NHibernate, but I believe that this bug exists in Hibernate too 'cause I've checked the code and the code is the same. Problem there that subquery from is implied and NHibernate (and Hibernate too) does not generate joins for subclasses in implied from clauses.

Project: Hibernate ORM
Labels: subclass hql join
Priority: Major Major
Reporter: Alexander I. Zaytsev
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira