I can't think of how to achieve this with a mapping. However, there are two approaches I can think of to solve the problem:
1. Use a getter property to get the "primary" child entity by iterating through the child collection, looking for the item with the IsPrimary property = true. In this case, everything is handled by your domain logic.
2. Add a foreign key on your parent entity table to the child entity table, pointing to the primary child for any given parent entity record. This works quite nicely as you can just set your "PrimaryChild" property to the proper Child instance and NHibernate will persist to the database appropriately.
|