Hi All
I've been tearing my hair out trying to resolve what I think must be a trivial mapping problem - but thus far the solution eludes me..
I have the following mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.nomogen.tegiri.hibernate.Bom_item" table="BOM_ITEM" >
<composite-id>
<key-property name="item_id" type="string" >
<column name="ITEM_ID" length="50" not-null="true" />
</key-property>
<key-property name="item_issue" type="string" >
<column name="ITEM_ISSUE" length="50" not-null="true" />
</key-property>
<key-property name="item_type_id" type="string" >
<column name="ITEM_TYPE_ID" length="1" not-null="true" />
</key-property>
</composite-id>
<many-to-one name = "part" class = "com.nomogen.tegiri.hibernate.Part" unique="true" lazy= "false" not-found = "ignore" fetch = "join" outer-join="true" insert="false" update="false">
<column name= "item_id" />
<column name= "item_issue" />
<column name= "item_type_id" />
</many-to-one>
</class>
</hibernate-mapping>
Despite all my best efforts, when retrieving Bom_item classes from the database, the first query executed Hibernate correctly contains an outer join to the Part table - but then Hibernate ALWAYS executes a second unnecessary query to retrieve the Part object.
Do I have an error in the mapping or am I missing somthing obvious? I do have <property name="hibernate.max_fetch_depth">3</property>
in the hibernate.cfg.xml file.
David