Looked like a bug to me. Tuna Toksöz Eternal sunshine of the open source mind.
http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Fri, Jul 31, 2009 at 2:41 PM, Saijado <[email protected]> wrote: > > I have this class-structure: > > class Parent{ > long Id{get;set;} > string Name{get;set;} > } > > with this mapping: > > <class name="Parent" > > <id name="Id"unsaved-value="0"> > <generator class="native" /> > </id> > <property name="Name"/> > <bag name="Children" access="none"> > <key column="ParentId" /> > <one-to-many class="Child" /> > </bag> > </class> > > I'm trying to get some Parents with a criteria: > > ISession session = sessionFactory.OpenSession(); > IList<Parent> parents; > using(session.BeginTransaction()) { > parents = session.CreateCriteria(typeof(Parent)) > .CreateCriteria("Children") > .Add(Expression.Eq("Name", name)) > .SetResultTransformer(Transformers.DistinctRootEntity ) > .List<Parent>(); > session.Transaction.Commit(); > } > > On Commit() an exception occours because NHibernate tries to update > the ParentId of the child with null. I've tried to use cascade="none" > but without any efect. If I have a private field with a List of > children in Parent there is no Problem. > > Why is Nhibernate doing this? > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
