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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to