Solved problem for brother-classes user, company which each one has a
single address using a many-to-one-relation. Methinks one can expand this to a many-to-many-relation.
Attention: You have to manually insert/update the Address-object before the User resp. Company.
Code:
class Address {.. };
class User { ... Address address ... };
class Company { ... Address address ... };
Mapping for class User is:
Code:
<class name="User">
...
<many-to-one name="address" class="Address" column="address_id" unique="false" not-null="false" />
</many-to-one>
...
</class>
Mapping for class Company is same. Mapping for class Address is
Code:
<class name="Address">
<id> ..</id>
...
</class>
(no back-link in address mapping).