Bidirectional associations and ownership
In NHibernate parlance, bidirectional associations have a notion of ownership. Ownership defines how the foreign key that underpins the bidirectional association is updated when new items are added to an association in memory. You can declare any end of the association to be the owner. Your choice of ownership affects the SQL that is generated in order to synchronize the association correctly to database. Let's elaborate this with an example.
Following diagram depicts the bidirectional relationship between the Employee
and Benefit
class:
The Employee to Benefit association is a bidirectional association which can also be seen as parent-child relation. Employee acts as parent and has multiple child benefits associated to it. From purely technical point of view, this is a one-to-many association. In one-to-many association, if ownership is not defined, then "one" side is considered as owner by default. So in our example, employee
is owner of the association...