The version is the version. The optimistic-lock strategy is the optimistic-lock strategy.If you are working with Version, each operation with a persistence instance mean change its state that mean change its version.
The optimistic-lock have place when an instance is flushed to DB. If you don't set the FlushMode explicit its value is FlushMode.Auto that mean, at least, that you are flushing the nh-session (that is the UoW) at transaction-commit. 2009/1/6 j gwood <[email protected]> > > Is there any way to have the Version property NOT incremented on > Session.SaveOrUpdate() or Session.Update() when using optimistic- > lock="false"? I am using setting optimisitic-lock to false in my > mapping file; however, NHibernate seems to be ignoring the optimistic- > lock attribute setting. Is there some other property that needs to be > set on my component or list? > > We are encapsulating NHibernate in our Persistence layer and using > Spring.NET to help manage transactions, so we are not exposing > ISession. The optimistic-lock attribute works when you don't call > Session.SaveOrUpdate and when you simply commit a transaction: > > s = OpenSession(); > t = s.BeginTransaction(); > gavin = (Person) s.CreateCriteria(typeof(Person)).UniqueResult > (); > new Task("Document", gavin); > t.Commit(); > s.Close(); > > My current mapping file as the following attributes set: > > <class name="Parent" table="Parent" schema="Simple" proxy="IParent" > optimistic-lock="version"> > <id name="Id" column="Id" type="Guid"> > <generator class="assigned"/> > </id> > <version name="Version" column="`Version`" type="Int32" unsaved- > value="0"/> > <property name="Name" column="`Name`" type="string" length="50" > optimistic-lock="false" /> > <list name="ChildrenInjector" inverse="true" generic="true" > cascade="all-delete-orphan" batch-size="10" optimistic-lock="false"> > <key column="ParentId"/> > <index column="SiblingIndex" type="Int32"/> > <one-to-many class="Child"/> > </list> > </class> > > Any suggestions are greatly appreciated, > > Jean > > > > -- 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 -~----------~----~----~----~------~----~------~--~---
