Hi all, I have a problem which I find hard to understand : when I delete a child object, the father gets deleted too.
The father is a class called FlightEntry. The children are classes FlightEntryService and FlightEntryDelay (both exchibit the same behaviour). The (ActiveRecord generated) hbm files are included below. The C# code is as simple as this (obviously m_editedObject as the FlightEntry being manipulated) : FlightEntryService svc = m_editedObject.FlightEntryServices[0]; svc.Delete(); And the sql being generated is this (I've confirmed it with sql profiler) : NHibernate: UPDATE FlightEntryDelay SET FlightEntryId = null WHERE FlightEntryId = @p0;@p0 = 1001 NHibernate: UPDATE FlightEntryService SET FlightEntryId = null WHERE FlightEntryId = @p0;@p0 = 1001 NHibernate: DELETE FROM FlightEntryService WHERE FlightEntryServiceId = @p0 AND LastVersion = @p1;@p0 = 1155, @p1 = 1 NHibernate: DELETE FROM FlightEntryDelay WHERE FlightEntryDelayId = @p0 AND LastVersion = @p1;@p0 = 468, @p1 = 1 NHibernate: DELETE FROM FlightEntryService WHERE FlightEntryServiceId = @p0 AND LastVersion = @p1;@p0 = 1156, @p1 = 1 NHibernate: DELETE FROM FlightEntryService WHERE FlightEntryServiceId = @p0 AND LastVersion = @p1;@p0 = 1157, @p1 = 1 NHibernate: DELETE FROM FlightEntry WHERE FlightEntryId = @p0 AND LastVersion = @p1;@p0 = 1001, @p1 = 3 The NHibernate.dll in use is 2.1.0.4000. Any ideas ? TIA, Dimitris Andrakakis -------------------- FlightEntry hbm : <?xml version="1.0" encoding="utf-16"?> <hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate- mapping-2.2"> <class name="OlympicHandling.Oly.ObjectModel.FlightEntry, OlympicHandling.Oly.ObjectModel" table="FlightEntry"> <id name="FlightEntryId" access="property" column="FlightEntryId" type="Int32" unsaved-value="0"> <generator class="native"> </generator> </id> <version name="EntityVersion" access="property" column="LastVersion" type="Int32" /> <property name="LastUser" access="property" type="String"> <column name="LastUser" length="40"/> </property> <property name="LastDate" access="property" type="System.DateTime"> <column name="LastDate" not-null="true" default="GetDate()"/> </property> <property name="LastWorkstation" access="property" type="String"> <column name="LastWorkstation" length="40"/> </property> <property name="ERPCode" access="property" type="String"> <column name="ERPCode" length="40"/> </property> <property name="InvoicingStatus" access="property"> <column name="InvoicingStatus" not-null="true" default="1"/> </property> <property name="FlightCommercialType" access="property"> <column name="FlightCommercialType" default="0"/> </property> <property name="Remarks" access="property" type="String"> <column name="Remarks" length="255"/> </property> <property name="ARRFlightCarrier" access="property" type="String"> <column name="ARRFlightCarrier" length="40"/> </property> <property name="ARRFlightNo" access="property" type="String"> <column name="ARRFlightNo" length="40"/> </property> <property name="ARRCodeShareCarrier" access="property" type="String"> <column name="ARRCodeShareCarrier" length="40"/> </property> <property name="ARRCodeShareFlightNo" access="property" type="String"> <column name="ARRCodeShareFlightNo" length="40"/> </property> <property name="SDA" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="SDA"/> </property> <property name="ADA" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ADA"/> </property> <property name="ARRCanx" access="property" type="Boolean"> <column name="ARRCanx"/> </property> <property name="ARRCanxDate" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ARRCanxDate"/> </property> <property name="ARRCanxTime" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ARRCanxTime"/> </property> <property name="ARRNoop" access="property" type="Boolean"> <column name="ARRNoop"/> </property> <property name="PaxInC" access="property" type="Int32"> <column name="PaxInC" default="0"/> </property> <property name="PaxInY" access="property" type="Int32"> <column name="PaxInY" default="0"/> </property> <property name="PaxInChd" access="property" type="Int32"> <column name="PaxInChd" default="0"/> </property> <property name="PaxInInf" access="property" type="Int32"> <column name="PaxInInf" default="0"/> </property> <property name="PaxInTransit" access="property" type="Int32"> <column name="PaxInTransit" default="0"/> </property> <property name="PaxInPad" access="property" type="Int32"> <column name="PaxInPad" default="0"/> </property> <property name="PaxInTotal" access="property" type="Int32"> <column name="PaxInTotal" default="0"/> </property> <property name="DeadLoadInBags" access="property" type="Int32"> <column name="DeadLoadInBags" default="0"/> </property> <property name="DeadLoadInCgo" access="property" type="Int32"> <column name="DeadLoadInCgo" default="0"/> </property> <property name="DeadLoadInMail" access="property" type="Int32"> <column name="DeadLoadInMail" default="0"/> </property> <property name="DeadLoadInTotal" access="property" type="Int32"> <column name="DeadLoadInTotal" default="0"/> </property> <property name="ARRFltRegion" access="property"> <column name="ARRFltRegion" default="0"/> </property> <property name="DEPFlightCarrier" access="property" type="String"> <column name="DEPFlightCarrier" length="40"/> </property> <property name="DEPFlightNo" access="property" type="String"> <column name="DEPFlightNo" length="40"/> </property> <property name="DEPCodeShareCarrier" access="property" type="String"> <column name="DEPCodeShareCarrier" length="40"/> </property> <property name="DEPCodeShareFlightNo" access="property" type="String"> <column name="DEPCodeShareFlightNo" length="40"/> </property> <property name="SDD" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="SDD"/> </property> <property name="ADD" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ADD_ACTDEPDATE"/> </property> <property name="DEPCanx" access="property" type="Boolean"> <column name="DEPCanx"/> </property> <property name="DEPCanxDate" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="DEPCanxDate"/> </property> <property name="DEPCanxTime" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="DEPCanxTime"/> </property> <property name="DEPNoop" access="property" type="Boolean"> <column name="DEPNoop"/> </property> <property name="PaxOutC" access="property" type="Int32"> <column name="PaxOutC" default="0"/> </property> <property name="PaxOutY" access="property" type="Int32"> <column name="PaxOutY" default="0"/> </property> <property name="PaxOutChd" access="property" type="Int32"> <column name="PaxOutChd" default="0"/> </property> <property name="PaxOutInf" access="property" type="Int32"> <column name="PaxOutInf" default="0"/> </property> <property name="PaxOutTransit" access="property" type="Int32"> <column name="PaxOutTransit" default="0"/> </property> <property name="PaxOutPad" access="property" type="Int32"> <column name="PaxOutPad" default="0"/> </property> <property name="PaxOutTotal" access="property" type="Int32"> <column name="PaxOutTotal" default="0"/> </property> <property name="DeadLoadOutBags" access="property" type="Int32"> <column name="DeadLoadOutBags" default="0"/> </property> <property name="DeadLoadOutCgo" access="property" type="Int32"> <column name="DeadLoadOutCgo" default="0"/> </property> <property name="DeadLoadOutMail" access="property" type="Int32"> <column name="DeadLoadOutMail" default="0"/> </property> <property name="DeadLoadOutTotal" access="property" type="Int32"> <column name="DeadLoadOutTotal" default="0"/> </property> <property name="DEPFltRegion" access="property"> <column name="DEPFltRegion" default="0"/> </property> <property name="ARROrigin" access="property" type="String"> <column name="ARROrigin" length="40"/> </property> <property name="ARRVia1" access="property" type="String"> <column name="ARRVia1" length="40"/> </property> <property name="ARRVia2" access="property" type="String"> <column name="ARRVia2" length="40"/> </property> <property name="DEPTo" access="property" type="String"> <column name="DEPTo" length="40"/> </property> <property name="DEPVia1" access="property" type="String"> <column name="DEPVia1" length="40"/> </property> <property name="DEPVia2" access="property" type="String"> <column name="DEPVia2" length="40"/> </property> <property name="STA" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="STA"/> </property> <property name="ETA" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ETA"/> </property> <property name="ATA" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ATA"/> </property> <property name="OBL" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="OBL"/> </property> <property name="ARRParkPos" access="property" type="String"> <column name="ARRParkPos" length="10"/> </property> <property name="ARRBelt" access="property" type="String"> <column name="ARRBelt" length="10"/> </property> <property name="STD" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="STD"/> </property> <property name="ETD" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ETD"/> </property> <property name="ATD" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ATD"/> </property> <property name="OFB" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="OFB"/> </property> <property name="DEPParkPos" access="property" type="String"> <column name="DEPParkPos" length="10"/> </property> <property name="DEPBelt" access="property" type="String"> <column name="DEPBelt" length="10"/> </property> <property name="CGOActLoad" access="property" type="Int32"> <column name="CGOActLoad" default="0"/> </property> <property name="CGOMaxPayload" access="property" type="Int32"> <column name="CGOMaxPayload" default="0"/> </property> <property name="BUSAVACMto" access="property" type="Int32"> <column name="BUSAVACMto" default="0"/> </property> <property name="SGT" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="SGT"/> </property> <property name="AGT" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="AGT"/> </property> <property name="DGT" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="DGT"/> </property> <property name="DelayTime" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="DelayTime"/> </property> <many-to-one name="CarrierId" access="property" class="OlympicHandling.Oly.ObjectModel.Carrier, OlympicHandling.Oly.ObjectModel" column="CarrierId" foreign- key="FK_Carrier_FlightEntry" lazy="proxy" /> <many-to-one name="AircraftId" access="property" class="OlympicHandling.Oly.ObjectModel.Aircraft, OlympicHandling.Oly.ObjectModel" column="AircraftId" foreign- key="FK_Aircraft_FlightEntry" lazy="proxy" /> <many-to-one name="Representative" access="property" class="OlympicHandling.Oly.ObjectModel.Carrier, OlympicHandling.Oly.ObjectModel" column="RepresentativeCarrierId" foreign-key="FK_Carrier_FlightEntry_Representative" lazy="proxy" /> <many-to-one name="FlightTypeId" access="property" class="OlympicHandling.Oly.ObjectModel.FlightType, OlympicHandling.Oly.ObjectModel" column="FlightTypeId" foreign- key="FK_FlightType_FlightEntry" lazy="proxy" /> <many-to-one name="LoadController" access="property" class="OlympicHandling.Oly.ObjectModel.LoadController, OlympicHandling.Oly.ObjectModel" column="LoadControllerId" foreign- key="FK_RampAgent_FlightEntry_LoadController" lazy="proxy" /> <many-to-one name="RampAgent" access="property" class="OlympicHandling.Oly.ObjectModel.RampAgent, OlympicHandling.Oly.ObjectModel" column="RampAgentId" foreign- key="FK_RampAgent_FlightEntry" lazy="proxy" /> <many-to-one name="StationId" access="property" class="OlympicHandling.Oly.ObjectModel.Station, OlympicHandling.Oly.ObjectModel" column="StationId" foreign- key="FK_Station_FlightEntry" lazy="proxy" /> <many-to-one name="HalfPositionId" access="property" class="OlympicHandling.Oly.ObjectModel.HalfPosition, OlympicHandling.Oly.ObjectModel" column="HalfPositionId" foreign- key="FK_HalfPosition_FlightEntry" lazy="proxy" /> <many-to-one name="ARRLandingTypeId" access="property" class="OlympicHandling.Oly.ObjectModel.LandingType, OlympicHandling.Oly.ObjectModel" column="ARRLandingTypeId" foreign- key="FK_LandingType_FlightEntry_Arrival" lazy="proxy" /> <many-to-one name="ARRFlightStatusId" access="property" class="OlympicHandling.Oly.ObjectModel.FlightStatus, OlympicHandling.Oly.ObjectModel" column="ARRFlightStatusId" foreign- key="FK_FlightStatus_FlightEntry_Arrival" lazy="proxy" /> <many-to-one name="DEPLandingTypeId" access="property" class="OlympicHandling.Oly.ObjectModel.LandingType, OlympicHandling.Oly.ObjectModel" column="DEPLandingTypeId" foreign- key="FK_LandingType_FlightEntry_Departure" lazy="proxy" /> <many-to-one name="DEPFlightStatusId" access="property" class="OlympicHandling.Oly.ObjectModel.FlightStatus, OlympicHandling.Oly.ObjectModel" column="DEPFlightStatusId" foreign- key="FK_FlightStatus_FlightEntry_Departure" lazy="proxy" /> <many-to-one name="DEPTimeOfDayId" access="property" class="OlympicHandling.Oly.ObjectModel.TimeOfDay, OlympicHandling.Oly.ObjectModel" column="TimeOfDayId" lazy="proxy" /> <bag name="FlightEntryDelays" access="property" table="FlightEntryDelay" lazy="false" cascade="all"> <key column="FlightEntryId" /> <one-to-many class="OlympicHandling.Oly.ObjectModel.FlightEntryDelay, OlympicHandling.Oly.ObjectModel" /> </bag> <bag name="FlightEntryServices" access="property" table="FlightEntryService" lazy="false" cascade="all"> <key column="FlightEntryId" /> <one-to-many class="OlympicHandling.Oly.ObjectModel.FlightEntryService, OlympicHandling.Oly.ObjectModel" /> </bag> </class> </hibernate-mapping> -------------------- FlightEntryService hbm : <?xml version="1.0" encoding="utf-16"?> <hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate- mapping-2.2"> <class name="OlympicHandling.Oly.ObjectModel.FlightEntryService, OlympicHandling.Oly.ObjectModel" table="FlightEntryService"> <id name="FlightEntryServiceId" access="property" column="FlightEntryServiceId" type="Int32" unsaved-value="0"> <generator class="native"> </generator> </id> <version name="EntityVersion" access="property" column="LastVersion" type="Int32" /> <property name="LastUser" access="property" type="String"> <column name="LastUser" length="40"/> </property> <property name="LastDate" access="property" type="System.DateTime"> <column name="LastDate" not-null="true" default="GetDate()"/> </property> <property name="LastWorkstation" access="property" type="String"> <column name="LastWorkstation" length="40"/> </property> <property name="ERPCode" access="property" type="String"> <column name="ERPCode" length="40"/> </property> <property name="FromTime" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="FromTime"/> </property> <property name="ToTime" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="ToTime"/> </property> <property name="Units" access="property" type="Int32"> <column name="Units" default="0"/> </property> <property name="HoursServiced" access="property" type="System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <column name="HoursServiced"/> </property> <many-to-one name="FlightEntryId" access="property" class="OlympicHandling.Oly.ObjectModel.FlightEntry, OlympicHandling.Oly.ObjectModel" column="FlightEntryId" foreign- key="FK_FlightEntry_FlightEntryService" cascade="all" lazy="proxy" /> <many-to-one name="ServiceId" access="property" class="OlympicHandling.Oly.ObjectModel.Service, OlympicHandling.Oly.ObjectModel" column="ServiceId" not-null="true" foreign-key="FK_Service_FlightEntryService" lazy="proxy" /> </class> </hibernate-mapping> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
