I have two entities A and B with the following relationship
How can I write hibernate mappings .hbm for A and B (hibernate 3, no annotations)?
You could create a composite identifier property in the parent class (e.g. A):
<properties name="ParentNaturalId">
<property name="prop1" column="prop_1" />
<property name="prop2" column="prop_2" />
</properties>
And the Client references the Parent through this many-to-one association:
<many-to-one name="parent" class="B" not-null="false" not-found="ignore" property-ref="ParentNaturalId" fetch="join">
<column name="b_prop_1" />
<column name="b_prop_2" />
</many-to-one>
not-found (optional - defaults to exception): specifies how foreign keys that reference missing rows will be handled. ignore will treat a missing row as a null association.
fetch (optional - defaults to select): chooses between outer-join fetching or sequential select fetching.