And, if I set the Parent's id generate policy to "identity", an error "null id generated for:NHTest.Child" would be thrown.
But things would be OK if I use "native" and provide an ID before saving. Blog: http://www.cnblogs.com/JeffreyZhao/ Twitter: http://twitter.com/jeffz_cn -------------------------------------------------- From: "hival" <[email protected]> Sent: Saturday, August 15, 2009 11:46 PM To: "nhusers" <[email protected]> Subject: [nhusers] Re: Lazy load of one-to-one association > > Hmm... > Here is my mapping and SQL (NH2.1.0) > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > assembly="NHTest" namespace="NHTest" auto-import="true"> > > <class name="Parent" table="parent"> > <id name="Id" column="p_id"> > <generator class="native" /> > </id> > > <property name="FieldA" column="p_field_a" /> > <one-to-one name="Child" class="Child" cascade="save-update" > constrained="true"/> > </class> > > <class name="Child" table="child" lazy="true"> > <id name="Id" column="c_id"> > <generator class="foreign"> > <param name="property">Parent</param> > </generator> > </id> > > <property name="FieldA" column="c_field_a" /> > <one-to-one name="Parent" class="Parent" constrained="true" /> > </class> > </hibernate-mapping> > > NHibernate: > /* load NHTest.Parent */ SELECT > parent0_.p_id as p1_0_0_, > parent0_.p_field_a as p2_0_0_ > FROM > parent parent0_ > WHERE > parent0_.p_...@p0; > @p0 = 1 > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
