Hello!
I have run into a little problem that I could not solve just by looking at the reference documentation. From the mapped class hierarchy below, I tried to fetch all DeviceBlock-instances that have no parent. As you can see, the parent property is inherited from the Component-class.
I used the following HQL-phrase:
"from DeviceBlock as db where db.parent is null"
However, this generates the wrong SQL as the parent-column has been placed in the DeviceBlock-table instead of the Component-table in the WHERE-clause.
What have I missed?
-Petter-
Hibernate version: 3.2.rc2
Mapping documents:
Code:
<class name="Component" table="component" abstract="true">
<id name="UUID" type="com.paroc.ttp.common.hibernate.UUIDType">
<generator class="com.paroc.ttp.common.hibernate.UUIDGenerator"/>
</id>
<version name="version" column="version" type="integer" unsaved-value="null"/>
<properties name="componentUniqueKey" unique="true" update="true" insert="true" optimistic-lock="true">
<property name="name" column="name" type="string" not-null="true"/>
<many-to-one name="parent" column="parent" class="Component"/>
</properties>
<property name="description" column="description" type="string"/>
<property name="hardware" column="hardware" type="string"/>
<property name="comments" column="comments" type="string"/>
<property name="revision" column="revision" type="string"/>
<property name="infoMissing" column="infoMissing" type="yes_no"/>
<property name="delivery" column="delivery" type="com.paroc.autosyst.device.domain.hibernate.ComponentDeliveryHT"/>
<bag name="children" inverse="true" cascade="all" lazy="false" order-by="name">
<key column="parent"/>
<one-to-many class="Component"/>
</bag>
<joined-subclass name="DeviceBlock" table="deviceBlock">
<key column="uuid"/>
<property name="attention" column="attention" type="string"/>
<property name="function" column="func" type="string"/>
<property name="name" column="name" type="string" insert="false" update="false" unique="true" not-null="true"/>
<!-- a few additional properties not included here -->
</joined-subclass>
</class>
Name and version of the database you are using: FireBirdSQL 1.5
The generated SQL (show_sql=true):Code:
select devicebloc0_.uuid as UUID0_, devicebloc0_1_.version as version0_, devicebloc0_1_.name as name0_, devicebloc0_1_.parent as parent0_, devicebloc0_1_.description as descript5_0_, devicebloc0_1_.hardware as hardware0_, devicebloc0_1_.comments as comments0_, devicebloc0_1_.revision as revision0_, devicebloc0_1_.infoMissing as infoMiss9_0_, devicebloc0_1_.delivery as delivery0_, devicebloc0_.attention as attention3_, devicebloc0_.func as func3_, devicebloc0_.name as name3_, devicebloc0_.project as project3_, devicebloc0_.section as section3_, devicebloc0_.software as software3_ from deviceBlock devicebloc0_ inner join component devicebloc0_1_ on devicebloc0_.uuid=devicebloc0_1_.UUID where devicebloc0_.parent is null