Setting the version from GUI ?Do you are setting the ID from GUI too ?

version for persistence-meaning must absolutely not available for read-write
in the GUI.
As I said, if you need something for business meaning you need another
property.



2008/10/1 Stefan Sedich <[EMAIL PROTECTED]>

>
> Still confuses me a little bit atm maybe I have had a long day but how
> is it going to help having a version for optimistic locking when I
> cannot set the version from a value stored with the GUI, I always
> thought this is how you would handle it.
>
> I will research to find a demo, is there any real demos out there
> doing what I wan't?
>
> On Wed, Oct 1, 2008 at 9:36 PM, Stefan Sedich <[EMAIL PROTECTED]>
> wrote:
> > Ok got my interceptor working, bit raw convert from the Hibernate one
> > I found but does what I wan't it to now, selects the version back from
> > the DB and does it correctly how I would like it to, thoughts?
> >
> >  public override bool OnFlushDirty(object entity, object id, object[]
> > currentState, object[] previousState, string[] propertyNames,
> > NHibernate.Type.IType[] types) {
> >            ISessionImplementor sessimpl =
> _session.GetSessionImplementation();
> >            IEntityPersister persister =
> sessimpl.GetEntityPersister(entity);
> >
> >            EntityMode mode =
> _session.GetSessionImplementation().EntityMode;
> >
> >            if(persister.IsVersioned) {
> >                object version = persister.GetVersion(entity, mode);
> >                object currentVersion =
> > persister.GetCurrentVersion(id, sessimpl);
> >
> >                if (!persister.VersionType.IsEqual(currentVersion,
> version))
> >                    throw new
> > StaleObjectStateException(persister.EntityName, id);
> >
> >            }
> >
> >            return base.OnFlushDirty(entity, id, currentState,
> > previousState, propertyNames, types);
> >        }
> >
> > On Wed, Oct 1, 2008 at 9:19 PM, Fabio Maulo <[EMAIL PROTECTED]>
> wrote:
> >> 2008/10/1 Stefan Sedich <[EMAIL PROTECTED]>
> >>>
> >>> So basically passing the version from my UI layer and setting it is
> >>> unsupported?
> >>
> >> No, it is understandable.
> >> As ID, version don't have business-meaning so you don't need to pass the
> >> version in your DTO because the version have only persistence-meaning.
> NH
> >> manage the version for optimistic-locking. The timestamp work only
> because
> >> it not depend from previous value (NH override any thing you are
> assigning).
> >> If you change the version by yourself you must manage optimistic-locking
> by
> >> yourself.
> >>
> >>>
> >>> Does anyone have any suggestions on how this is achieved?
> >>> I am yet to find anything out there.
> >>
> >> Yes. Don't touch the version and let NH do it for you.
> >> The other option is to have 2 "version" properties. One for your
> business
> >> meaning and the other for persistence-meaning (the first read-write the
> >> second nosetter).
> >> --
> >> Fabio Maulo
> >>
> >> >>
> >>
> >
> >
> >
> > --
> > Stefan Sedich
> > Developer
> > Microsoft Certified Professional (MCP)
> >
>
>
>
> --
> Stefan Sedich
> Developer
> Microsoft Certified Professional (MCP)
>
> >
>


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