It seems that If I evict my object out of the session it works, why
would this be the case? I am selecting first so my child collections
are not lost and I can map across the values from my DTO, this worked
fine with a TimeStamp version column don't see why the integer is
different maybe becuase the int is incremented by NH?

On Oct 1, 2:23 pm, codemonkey <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I recently changed all my RowVersion columns to use an integer instead
> of the timestamp I was using, my optimistic locking was working
> previously and the error would be thrown if I opened up the same
> record and edited one, then edited the same version.
>
> My service method firsts selects the record maps across from my DTO
> and updates, no data acess code has changed just the RowVersion column
> has changed. Any ideas would be great this is driving me nuts:
>
>  public void Update(CourseUpdateDTO courseDTO) {
>
>             // Load the existing course.
>             var course =
> this.courseRepository.SelectById(courseDTO.Id);
>
>             // Map properties across.
>             course.CricosCode = courseDTO.CricosCode;
>             course.Description = courseDTO.Description;
>             course.InternalCode = courseDTO.InternalCode;
>             course.Title = courseDTO.Title;
>             course.RowVersion = courseDTO.RowVersion;
>
>             // Validate the model and update using the repository.
>             course.Validate();
>             this.courseRepository.Update(course);
>
>         }
>
> Mapping:
>
> <?xml version="1.0" encoding="utf-8"?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
>   <class name="Course" table="Courses" lazy="false">
>     <id name="Id" column="ID" type="int">
>       <generator class="native" />
>     </id>
>     <version name="RowVersion" column="RowVersion" unsaved-value="0" /
>
>     <many-to-one name="Institution" column="InstitutionID"
> cascade="none" not-null="true" fetch="join" />
>     <many-to-one name="SubjectArea" column="SubjectAreaID"
> cascade="none" not-null="true" fetch="join" />
>     <property name="Title" column="Title" type="string" />
>     <property name="CricosCode" column="CRICOSCode" type="string" />
>     <property name="InternalCode" column="InternalCode" type="string" /
>
>     <property name="Description" column="Description" type="string" /
>
>     <set name="CourseSemesters" inverse="true" lazy="true"
> cascade="delete-orphan">
>       <key column="CourseID" />
>       <one-to-many
> class="Phoenix.Link2Uni.ApplicationManager.Model.CourseSemester,Phoenix.Lin 
> k2Uni.ApplicationManager.Model" /
>
>     </set>
>   </class>
> </hibernate-mapping>
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
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