Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibenate cascade problem
    text
    copied!<p>Hi I'm having a problem updating child objects in the following scenario.</p> <p>The mappings are as follows:</p> <p>Parent: Calendar</p> <pre><code> &lt;bag name="defaultCategories" inverse="true" lazy="false" cascade="all-delete-orphan"&gt; &lt;key column="parentID" /&gt; &lt;one-to-many class="DefaultCategory"/&gt; &lt;/bag&gt; </code></pre> <p>Child: DefaultCatergory</p> <pre><code>&lt;class name="DefaultCategory" table="tb_calendar_default_category" lazy="false"&gt; &lt;id name="id" column="id"&gt; &lt;generator class="hilo"/&gt; &lt;/id&gt; &lt;many-to-one name="calendar" column="parentID" not-null="true" cascade="all-delete-orphan" /&gt; </code></pre> <p>Code used to update calendar:</p> <pre><code>public Calendar Update(Calendar vo) { session = NHibernateHelper.GetCurrentSession(); tx = session.BeginTransaction(); using (tx) { session.Update(vo); tx.Commit(); } return vo; } </code></pre> <p>The problem is that when I add or delete defaultCategories via the ui and send back the updated version of the calendar to the back end, NHibernate returns the updated calendar and all seems well. However any defaultCatergories which should have been deleted are left in the default Categories table. Thus when I refresh the ui and call for the calendar again, I can see collection has not changed.</p> <p>Do you think I need to delete all defaultCatergories by parentID and then recreate? I was under the impression NHibernate took care of this for you? Any help or pointers much appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload