http://nhforge.org/doc/nh/en/index.html#manipulatingdata-flushing
http://nhforge.org/doc/nh/en/index.html#transactions-optimistic

2009/1/6 Fabio Maulo <[email protected]>

> I'm sure that there is something saying the difference between a
> session.Save, session.Update, session.Delete and session.Flush...If I well
> remember was one of the first thing I learn in NH.
> BTW some concepts are here
> http://fabiomaulo.blogspot.com/2008/12/identity-never-ending-story.html
>
> 2009/1/6 j gwood <[email protected]>
>
>
>> Hibernate documentation states the following for a property (5.1.11):
>>
>> "(10)   optimistic-lock (optional - defaults to true): Specifies that
>> updates to this property do or do not require acquisition of the
>> optimistic lock. In other words, determines if a version increment
>> should occur when this property is dirty. "
>>
>> However, none of the doucmentation that I could find discusses the
>> difference between flushing the session and explicitly calling Save
>> ().  Even if I save an object without making any changes to it, the
>> version property gets incremeted.
>>
>> Jean
>>
>> On Jan 6, 10:43 am, "Fabio Maulo" <[email protected]> wrote:
>> > NHiA is based on NH1.2 (very old version at this point) and is strange
>> that
>> > I don't know that feature.I'll review the H3.3.0 code to check if that
>> is a
>> > real feature supported by Hibernate.
>> >
>> > 2009/1/6 j gwood <[email protected]>
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Thank you for the explanation on version versus optimistic-lock.  The
>> > > following text from the NHibernate In Action book led me to believe
>> > > that you could disable the version increment using the optimistic-lock
>> > > attribute (page 129 of Kuate_NHibernate_MEAP_0804.pdf):
>> >
>> > > "It is possible to disable the increment of the version when a
>> > > specific property is dirty. To do so, you must add  optimistic-
>> > > lock="false" to this property's mapping. This  feature is available
>> > > for properties, components and collections (the owning entity's
>> > > version is not incremented). "
>> >
>> > > The book does not mention the difference between session.save() and
>> > > flushing the session with transaction.commit().
>> >
>> > > My company requires the functionality to save an object without having
>> > > the version incremented when certain properties are modified.
>> >
>> > > Jean
>> >
>> > > On Jan 6, 9:53 am, "Fabio Maulo" <[email protected]> wrote:
>> > > > 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- Hide quoted text -
>> >
>> > > > - Show quoted text -
>> >
>> > --
>> > Fabio Maulo- Hide quoted text -
>> >
>> > - Show quoted text -
>> >>
>>
>
>
> --
> Fabio Maulo
>



-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to