I have two entities: Person and Contact. These have a one to one relationship (in the database each has an Id foreign key to the other). I cannot use the one to one mapping in NHibernate because of this bug <https://nhibernate.jira.com/browse/NH-2534> causing a lot of very terrible N+1 issues so instead have mapped the association as many-to-one from both directions:
<many-to-one name="Contact" class="Contact, Common" cascade="all"> <column name="ContactId" sql-type="int" not-null="true" index="FK_Person_Contact"/> </many-to-one> <many-to-one name="Person" class="Person, Common" cascade="all"> <column name="PersonId" sql-type="int" not-null="true" index="FK_Contact_Person"/> </many-to-one> When trying to save a new set of these items, I am getting the common null or transient error that always seems to be related to people not setting the cascade property in their mapping. As you can see I have cascade set to all. Is there something about doing this bi-directional many to one that causes this issue to occur. I would like to leave the not-null="true" on both sides of the relationship if possible as no record of either type can exist in the database without the other. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/VxBOKJIU0KgJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
