Discussion:
[nhusers] Delete child table data using bag
ANIL R
2018-03-27 12:36:38 UTC
Permalink
Hi,

I have a Parent object(Table) which has some(n no.of) properties and some(n
no.of) components. One of the component(component n in sample code) has
list of data.
Using bag to map the list. I am able to store the data as expected but not
able to delete. When I try to delete, getting the exception :

NHibernate.Exceptions.GenericADOException: could not execute update
query[SQL: delete from table_name where pk_column=?] --->
System.Data.SQLite.SQLiteException: constraint failed
FOREIGN KEY constraint failed

May I know why I am not able to delete?

Please find the mapping below:

<class name="Parent" lazy="false">
<id name="DbId" unsaved-value="0">
<generator class="native" />
</id>

<property name="Property1"/>
<property name="Property2"/>
.
.
<property name="Propertyn"/>

<component name="a">
<property name="a1" />
<property name="a2" />
</component>

<component name="b">
<property name="b1" />
<property name="b2" />
</component>
.
.
.

<component name="n">
<property name="n1" />
<property name="n2" />
<bag name="datalist" lazy="false" fetch="subselect" cascade="all">
<key column="DbId" />
<element type="int" column="data" />
</bag>
</component>
</class>
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Loading...