http://www.nhforge.org/doc/nh/en/index.html#example-parentchild

This is a good read.  In your specific case 19.3 talks about this:
Cascading Lifecycle.

You probably want inverse=true (since the child has many-to-one back
to parent) and cascade = all-delete-orphan.

On Jul 27, 9:26 pm, Ian Escarro <[email protected]> wrote:
> I have an error in deleting a master/detail relationship. I have a
> PurchaseOrder class and a PurchaseOrderItem class. These are the mapping.
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>     namespace="Bogetz.Elephant.Model" assembly="elephant">
>
>     <class name="PurchaseOrder" table="purchase_orders">
>         <id name="Id">
>             <generator class="native"/>
>         </id>
>         <property name="Date"/>
>         <many-to-one name="Vendor" class="Vendor" column="VendorId"/>
>         <bag name="Items" cascade="all">
>             <key column="POId"/>
>             <one-to-many class="PurchaseOrderItem"/>
>         </bag>
>         <property name="PreparedBy"/>
>         <property name="ApprovedBy"/>
>         <property name="ReferenceNo"/>
>     </class>
>
>     <class name="PurchaseOrderItem" table="purchase_order_items">
>         <id name="Id">
>             <generator class="native"/>
>         </id>
>         <many-to-one name="Order" class="PurchaseOrder" column="POId"/>
>         <many-to-one name="Item" class="Item" column="ItemId"/>
>         <property name="UnitPrice"/>
>         <property name="Quantity"/>
>         <property name="Amount"/>
>     </class>
>
> </hibernate-mapping>
>
> and when I issue someSession.Delete(PurchaseOrder) it throws the exception
> above. I need help in finding the things I missed. Thanks in advance.
>
> ---
> Ian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to