Thanks for the tip! I have removed all not-found="ignore" from my project, and the code works now. I only had them in there because I misunderstood the meaning of the not-found property, and there were no erroneous foreign key references in the database. The problem is resolved, but can you tell me why it does not work with not- found="ignore"?
On Apr 28, 11:16 am, Fabio Maulo <[email protected]> wrote: > <many-to-one name="VcoaInstrData" class="VcoaInstrData" not-null="false" > not-found="ignore"> > <one-to-many class="VcoaData" not-found="ignore" /> > > Those not-found=ignore smells very bad about the state of your DB. > > > > On Thu, Apr 28, 2011 at 12:08 PM, spiffcow <[email protected]> wrote: > > I have a situation where NHibernate will not lazy load a property two > > degrees removed from the initial object, *except* when that property > > is marked as cascade="all". I think this is a bug, but it could just > > be a misunderstanding on my part about the relationship between lazy > > loading and cascade options. Either way, any information/advice about > > this would be appreciated. > > > My C# code looks like this: > > > var initialObject = <get object of type TextualDepartureProcedure from > > the session...> > > var targetObj = TextualDepartureProcedure.VcoaInstrData.Vcoas.First(); > > > This fails with a lazy load initialization exception.. But if I > > change the TextualDepartureProcedure to VcoaInstrData cascade to > > "all", the properties are lazily loaded correctly. > > > My hbms look like this (non-pertinent data removed): > > > <?xml version="1.0" encoding="utf-8" ?> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > namespace="Org.Ifp.Departure.Data" assembly="Org.Ifp.Departure.Data"> > > <class name="TextualDepartureProcedure" table="V_T_DPRT_PROC"> > > <composite-id> > > <key-property name="RevNbr" column="REV_NBR" > > type="Int32" /> > > <key-property name="Uuid" column="UUID" type="Guid" > > /> > > </composite-id> > > <many-to-one name="VcoaInstrData" class="VcoaInstrData" not- > > null="false" cascade="none" not-found="ignore"> > > <column name="VCOA_INSTR_UUID" /> > > </many-to-one> > > </class> > > </hibernate-mapping> > > > <?xml version="1.0" encoding="utf-8" ?> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > namespace="Org.Ifp.Departure.Data" assembly="Org.Ifp.Departure.Data"> > > <class name="VcoaInstrData" table="V_VCOA_INSTR"> > > <id name="Uuid" column="UUID" type="Guid"> > > <generator class="assigned" /> > > </id> > > <bag name="Vcoas" table="V_VCOA" lazy="true" > > cascade="save-update" > > inverse="true"> > > <key> > > <column name="VCOA_INSTR_UUID" /> > > </key> > > <one-to-many class="VcoaData" not-found="ignore" /> > > </bag> > > <many-to-one name="TextualDepartureProcedure" > > class="TextualDepartureProcedure" not-null="false" cascade="none" not- > > found="ignore"> > > <column name="T_DPRT_PROC_REV_NBR" /> > > <column name="T_DPRT_PROC_UUID" /> > > </many-to-one> > > </class> > > </hibernate-mapping> > > > <?xml version="1.0" encoding="utf-8" ?> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > namespace="Org.Ifp.Departure.Data" assembly="Org.Ifp.Departure.Data"> > > <class name="VcoaData" table="V_VCOA"> > > <id name="Uuid" column="UUID" type="Guid"> > > <generator class="assigned" /> > > </id> > > <many-to-one name="VcoaInstData" class="VcoaInstrData" not- > > null="false" cascade="save-update" not-found="ignore"> > > <column name="VCOA_INSTR_UUID" /> > > </many-to-one> > > </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. > > -- > Fabio Maulo -- 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.
