Fluent nHibernate: one-to-many relationship Issue

后端 未结 2 1460
鱼传尺愫
鱼传尺愫 2020-12-16 07:47

I have a problem with one-to-many relationships. I have the following domain classes:

public class Installation : Entity
{        
    pu         


        
2条回答
  •  执笔经年
    2020-12-16 08:18

    When you have a persistent collection with inverse="false", then the parent object owns the relationship and any changes to the parent's collection will be reflected in the database.

    When you have a persistent collection with inverse="true", then the child object owns the relationship and any changes to the child's reference to the parent will be reflected in the database.

    Because you set inverse="true", you will need to change the child object's reference to the parent object in order for NHibernate to pick up on it. If you wish NHibernate to pick up on the changes to the relationship whenever you add children to or remove children from the parent's collection, you must set inverse="false" on the collection.

提交回复
热议问题