Joined: Mon Aug 13, 2007 7:54 am Posts: 2
|
Hello,
I have got a problem with a 1:N Relationship.
I have got two classes called Customer.java and ContactPerson.java.
-One Customer can have many ContactPersons. So I put a Set of ContactPersons into the class Customer.
-One ContactPerson can have just one Customer.
Thats why there is a Customer attribute in the ContactPerson class.
There are two Database tables: one called Customer and one called ContactPerson. In the ContactPerson-Table is a column called Customer_OID. It referenced the Customer.
In the Mapping files i wrote:
ContactPerson.hbm.xml:
-----------------------------
<many-to-one name="customer" class="customer" fetch="select">
<column name="customer_OID" not-null="true" />
</many-to-one>
Customer.hbm.xml:
-----------------------------
<set name="contactPersons" inverse="true">
<key>
<column name="customer_OID" not-null="true" />
</key>
<one-to-many class="ContactPerson" />
</set>
In Both Mapping files is default-lazy="false" set.
Well now I fetched a ContactPerson out of the Database and the Customer is fetched out too.
Thats right.
I fetched a Customer out of the Database and the proper ContactPersons are not fetched with it.
Can somebody please help and explain me what i did wrong?
I want that the ContactPersons are loaded with the proper Customer!
Thanks
|
|