Hello
My question is about many-to-one or one-to-one mapping.
I have a Profile and BillingInfo classes.
Code:
<class name="Profile" table="Profile">
<id name="Id">
<column name="Id" not-null="true" />
<generator class="native" />
</id>
<set name="BillingInfos" cascade="delete" inverse="true" lazy="true">
<key column="ProfileId" on-delete="cascade" />
<one-to-many class="BillingInfo" />
</set>
</class>
Code:
<class name="BillingInfo" table="BillingInfo">
<id name="Id">
<column name="Id" not-null="true" />
<generator class="native" />
</id>
<property name="Primary" column="[Primary]" not-null="true" />
<many-to-one name="Profile" class="Profile" column="ProfileId" not-null="true" cascade="none" update="false" fetch="select"/>
</class>
One Profile can have many BillingInfo, but only one of them is the default BillingInfo. The first point (simple one-to-many) is easy to implement.
The question is how to implement the second point, i.e. Profile can have only one BillingInfo.
Thank you in advance.