Hi guys
Quoting from the manual.
Quote:
8.2.3. One-to-many
A unidirectional one-to-many association on a foreign key is an unusual case, and is not recommended.
Code:
<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
<set name="addresses">
<key column="personId"
not-null="true"/>
<one-to-many class="Address"/>
</set>
</class>
<class name="Address">
<id name="id" column="addressId">
<generator class="native"/>
</id>
</class>
You should instead use a join table for this kind of association.
I would like to manipulate Addresses from the Person POJO not other way around and not by using join table.
exmaple:
Person.addAddress(address1);
Person.addAddress(address2);
Person.addAddress(address3);
and not
Address.setPerson(person);
I'm wondering why is this case unusual (by the manual).
Regards
Armando