My class has a nullable guid property which is not it’s identifier. The guid is used to group records in a specific way, so that many records can have the same guid.
Everytime I update some other property, nhibernate updates the guid, which is not the desired result.
Here’s the mapping:
<class name="MyClass" table="SomeTable">
<id name="Id" column="SomeTableId" type="Int32" >
<generator class="native">
<param name="sequence">SomeTableSequence</param>
</generator>
</id>
<property name="Instant" column="Instant" />
<property name="Value" column="Value" />
<property name="Description" column="Description" />
<property name="Group" column="GroupId" /> <!-- this is the GUID -->
</class>
What should I do to stop this behavior?
Update
I forgot to mention that I’m simply doing an ISession.Update call:
public void Update(MyClass myInstance) {
_session.Update(myInstance);
_session.Flush();
}
Since I didn’t have much time available, I ended up doing the update “by hand”. I’ll gladly accept another answer, if any.