0

I am using NHibernate for DB connection for the following classes:

Class A
{
   public int Id{get;set;}
   public List<B> InnerElements{get;set;}

}

Class B
{
   public int Id{get;set;}
   public string Description{get;set;}
   ...no reference to the parent
}

and in the DB i have As (to class A), Bs(to class b) and ABs tables where the table ABs has an autoincremented id, and the ids of A and B entities.

The configuration files for the classes are:

Class A

...other properties mapped
<bag name="InnerElements" table="ABs" cascade="all" inverse="true">
      <key column="AID" />
      <many-to-many class="B" column="BID"/>
    </bag>

and in the class B i dont have any refferences to class A.

When I remove an B element from the InnerElements from an entity of type A, and try to Save/Update the modified entity back to the DB, the inner ABs table remains unmodified. How can I change (in the config files or otherwise) to remove the entry from the inner table ? I dont want to remove any A or B entry from DB.

Thanks in advance, Tamash

Tamas Ionut
  • 4,240
  • 5
  • 36
  • 59

1 Answers1

1

Remove the inverse="true". That attribute, which looks copy&pasted, means you are handling the relationship from the other side, which does not exist in this case.

Diego Mijelshon
  • 52,548
  • 16
  • 116
  • 154