Hi Markus, I don't have any idea about the deletion problem, but about the " lazily loading the diagnosis (despite the join!) " i can tell you that if you like to load the *Diagnosis *eagerly, you need to do *join fetch *and not just * join.*
2011/12/22 Markus Ewald <[email protected]> > On 12/22/2011 2:11 PM, Markus Ewald wrote: > >> I've got a weird problem: >> NHibernate is issuing 'DELETE FROM' statements on my database even though >> I am merely retrieving a list of records (that I am not even accessing >> anymore now). >> >> [...] >> >> var plans = Session.CreateCriteria<**TreatmentPlan>() >> .SetFetchMode("Diagnosis", FetchMode.Join) >> .SetFirstResult(start) >> .SetMaxResults(maxCount) >> .SetResultTransformer(**Transformers.**DistinctRootEntity); >> .List<TreatmentPlan>() >> >> plans = new List<TreatmentPlan>(); // Do NOT touch plans returned by >> NHibernate at all after this >> >> > I tried to same in HQL. > > var query = Session.CreateQuery( > @" > select plan > from TreatmentPlan plan > join plan.Diagnosis diag where plan.Diagnosis.Id = diag.Id > " > ); > var plans = query > .SetFirstResult(start) > .SetMaxResults(maxCount) > .List<TreatmentPlan>(); > > Not only is it lazily loading the diagnosis (despite the join!), it > happily continues issuing DELETE FROM commands to the database. > I also tried liberally sprinkling 'cascade="none"' in all affecting > mappings to see if I could NHibernate to change its behavior in any way, > but no luck. > > This is pretty scary behavior, I must say. > > -Markus- > > -- > 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 nhusers+unsubscribe@** > googlegroups.com <nhusers%[email protected]>. > For more options, visit this group at http://groups.google.com/** > group/nhusers?hl=en <http://groups.google.com/group/nhusers?hl=en>. > > -- Itzik Saban my blog <http://itziksaban.blogspot.com/> -- 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.
