we can use magical property-ref
setting:
on parent side (class A), collection mapping:
<bag name="Children" lazy="true" inverse="true"
batch-size="25" cascade="all-delete-orphan" >
<key column="Name" property-ref="Name" />
<one-to-many class="B"/>
</bag>
and child (class B) can reference parent similar way:
<many-to-one not-null="true" name="Parent" class="A"
property-ref="Name" column="Name" />
check also: https://stackoverflow.com/a/31300425
A link to doc: 5.1.11. many-to-one
...
property-ref
: (optional) The name of a property of the associated
class that is joined to this foreign key. If not specified, the
primary key of the associated class is used.