Hi,

I am trying to write nhibernate mapping file for a parent-child
relationship but not able to get the expected behavior while saving
object child object. I have already tried all permutation-combination
of attribute values but no luck. Please help.

Parent and Child have one-to-many relationship. Below is the mapping I
am using. I need to get a behavior so that if I save Parent object
then it's Child objects are also saved automatically (if any changes
done to existing child object or new child is added in list). But when
I save Child object then Parent object data should not be saved in
database automatically with Child's save (so if I need to save Parent
data then that should be done separately using another save on Parent
object).

Parent xml,
    <bag name="CityList" table="City" inverse="true" lazy="true"
cascade="save-update">
        <key column="StateId"/>
        <one-to-many class="City"/>
    </bag>


Child xml,
    <many-to-one name="StateObject" column="StateId" class="State"
update="true" insert="true" not-found="ignore" not-null="false"/>

-- 
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.

Reply via email to