Sorry for the delay.

Can you please elaborate on what you need to do?

Any checks that are done by NH (not-null, uniqueness, version etc.)
are only performed while flushing. Calling Save() won't do anything
within a SessionScope when the object is already persistent (this is
the case when you use ARDataBind).
My preferred option to handle this is calling Flush() manually,
catching errors and evicting the offending objects in the exception
handler.

-Markus

2009/2/6 Simon <laroche.si...@gmail.com>:
>
> I have trying to use the ActiveRecord DataBinder in conjunction with a
> Version field and I could not get a stale object object exception when
> the session got flushed.
>
> The only way I could get a stale object exception was by evicting and
> then updating the entity.
>
> For example:
>
> public void Update([ARDataBind("fournisseur",
> AutoLoadBehavior.Always)] Fournisseur fournisseur)
> {
>        ActiveRecordMediator.Evict(fournisseur); //Required to get a stale
> object exception
>        ActiveRecordMediator.Update(fournisseur); //
>
>        if(!Validator.IsValid(fournisseur))
>        {
>                PropertyBag.Add("errorSummary", Validator.GetErrorSummary
> (fournisseur));
>                PropertyBag.Add("fournisseurType", typeof(Fournisseur));
>                PropertyBag.Add("fournisseur", fournisseur);
>                MyViews.edit.Render();
>                return;
>        }
>
>        MyActions.Index().Redirect();
> }
>
> I think that it is how NHibernate works since the entity already
> belongs to the session when the binder changes the version value.
>
> Is there a way to configure NHibernate to check for the version before
> saving, a configuration, an interceptor or should I just make my own
> databinder that evicts and then update my entity?
>
> I'm using the trunk version of Castle.
>
> //Simon
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to