Hibernate version: 2.1.6
Mapping documents:
Code:
<hibernate-mapping package="example">
<class name="MyObject" table="OBJECTS">
<id
column="OBJ_ID"
name="id"
type="integer"
>
<generator class="vm" />
</id>
<property
column="OBJ_NAME"
length="150"
name="name"
not-null="false"
type="string"
/>
<joined-subclass name="Instrument" table="INSTRUMENTS">
<key column="INT_ID" />
<property
column="INT_NAME"
length="150"
name="name"
not-null="false"
type="string"
/>
</joined-subclass>
</class>
</hibernate-mapping>
Name and version of the database you are using:Oracle 8.1.7
The generated SQL (show_sql=true):Code:
SELECT instrument0_.obj_name AS x0_0_
FROM INSTRUMENTS instrument0_, OBJECTS instrument0__1_
WHERE instrument0_.roo_id = instrument0__1_.obj_id
HQL sentCode:
select int.name
from Instrument int
As you can see the SQL can't work because it uses the wrong column name on the wrong table.
I know I should just remove the property on Instrument but it was used in the legacy schema and it still need to be updated. And it could improve query performance (this HQL could use only INSTRUMENT and not even join with OBJECTS)
Is this a known bug ? Any workaround ?