Hello,
Ran out of ideas what may be wrong, please help.
Hibernate 3, one-to-many relation: I can see in the log that hibernate selects children (and the query returns what expected) but the Collection property in the parent object is still empty. Would appreciate any hints as it has been a few days and I just have no single idea left. Here's the mapping XML:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Parent" table="PARENT">
<id name="id" column="PARENT_REF_NUM" />
<set name="children" inverse="true">
<key column="PARENT_REF_NUM"/>
<one-to-many class="Child" />
</set>
</class>
<class name="Child" table="CHILD">
<composite-id>
<key-many-to-one name="parent" class="Parent" column="PARENT_REF_NUM"/>
<key-property name="seqNum" column="SEQ_NUM"/>
</composite-id>
<property name="childName" column="CHLD_NME"/>
</class>
</hibernate-mapping>
The code:
Parent parent = hbSession.load(Parent.class, "parent0");
System.out.println(parent.getId()+","+parent.getChildren().size());
prints "parent0, 0"
but the query that hibernate generated to select children, if executed in an SQL tool actually returns the whole bunch of children..
please help,
Max.