Hi,
I have a parent to child relationship.
My problem is, when I access the child object, and afterward flushes the session, NHibernate automatically UPDATE's the child objects with the same values (no differences).
This will issue an update of the child:
Response.Write(Profile.ProfilePicture.Filename);
_session.Flush();
Can anyone see why this happens? I of course don't want to update the child in this scenario.
Here is my hibernate mapping:
Parent:
<class name="Business.Domain.Profile, Business" table="Profiles">
<id name="Id" type="int">
<generator class="native" />
</id>
<property name="Username" type="string" length="100" />
<property name="Password" type="string" length="200" />
<property name="Email" type="string" length="150" />
<property name="CreatedDate" generated="insert" />
<property name="LastLoginDate" />
<property name="LastActivityDate" />
<property name="Firstname" type="string" length="50" />
<property name="Lastname" type="string" length="50" />
<property name="Fullname" formula="Firstname + ' ' + Lastname" />
<property name="Gender" not-null="true" type="int" />
<property name="Description" not-null="false" type="string" />
<many-to-one
name="ProfilePicture"
column="ProfilePictureId"
class="Business.Domain.Picture, Business" />
<set name="Pictures" generic="true" inverse="true" cascade="all-delete-orphan">
<key column="ProfileId" />
<one-to-many class="Business.Domain.Picture, Business"/>
</set>
</class>
Child:
<class name="Business.Domain.Picture, Avando.Business" table="Pictures">
<id name="Id" type="int">
<generator class="native" />
</id>
<property name="Filename" type="string" />
<property name="CreatedDate" type="DateTime" generated="insert" />
<many-to-one
name="Profile"
column="ProfileId"
class="Business.Domain.Profile, Business"
not-null="true" />
</class>