The test in NH, where we are using MsSQL-timestamp and generated="always", is NHibernate.Test.VersionTest.Db.MsSQL If you want browse of NH2.1.x the test is here http://tinyurl.com/yjxoben **
2009/12/1 sebring <[email protected]> > Sorry Fabio, I didn't have my code in front of me when I posted. > > The version tag looks like this in my generated code (I am using an > FNH mapping) like this: > > this.Version(x => x.Version).Column("Version").Generated.Always > ().UnsavedValue("null"); > > This generates the following tag: > > <version column="Version" generated="always" name="Version" > type="System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089" unsaved-value="null" /> > > But the problem still remains. Any thoughts? > > On Dec 1, 8:15 am, Fabio Maulo <[email protected]> wrote: > > 1) the title are talking about Timestamp but you are using <version> > > 2) that mapping is not using MsSQL timestamp but a int version > > 3) the unsaved value cant be string empty > > > > 4) if you need help, please try to send something real > > Thanks. > > > > 2009/12/1 sebring <[email protected]> > > > > > > > > > > > > > I have an entity mapped in NHibernate with optimistic concurrency > > > control using a SQL timestamp column as the version number. The > > > mapping is like the following: > > > > > <class name="Entity" optimistic-lock="version" discriminator- > > > value="0"> > > > <id name="id"> > > > <generator class="native" /> > > > </id> > > > <version column="Version" generated="always" unsaved-value="" /> > > > ... > > > <subclass name="ChildEntity" discriminator-value="1" /> > > > </class> > > > > > I am testing what happens when the data in a row in the database > > > changes between the get and the update of the record. To do so, I am > > > running an update statement directly against one of the records in the > > > table that are in the process of being updated by NHibernate. This > > > direct update changes the version number of the record in the table. > > > > > As expected, the NHibernate managed update does not occur on the > > > specific row (this is good). However, no exception is thrown during > > > the commit. I expected a StaleObjectStateException to occur when the > > > transaction was committed so that I could roll back the transaction > > > and inform the user. Isn't this the expected behavior? Am I missing > > > something? > > > > > My code to commit the transaction looks something like this: > > > > > _session.BeginTransaction(); > > > ... > > > // load objects in session > > > IList<ChildEntity> toChange = (load objects to change using _session > > > query) > > > foreach ( var itemToChange in toChange ) > > > { > > > itemToChange.Status = Status.Updated; > > > } > > > ... > > > _session.Transaction.Commit(); > > > > > The items belong to the same session and all work is completed within > > > a single transaction. ChildEntity is a subclass of the Entity base > > > class, which has the optimistic-lock set to version. > > > > > What am I missing? > > > > > -- > > > > > 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]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en. > > > > -- > > Fabio Maulo > > -- > > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > > -- Fabio Maulo -- 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.
