RE: ActiveRecord and validation

0 views
Skip to first unread message

David N. Godfrey

unread,
Apr 30, 2007, 4:54:20 AM4/30/07
to castle-pro...@googlegroups.com

Yes - ActiveRecord has already caught the exception and either flushes
directly when it releases the session or if it is part of a scope the
scope flushes when it is closed.

Dave.


-----Original Message-----
From: castle-pro...@googlegroups.com
[mailto:castle-pro...@googlegroups.com] On Behalf Of Hamilton
Verissimo
Sent: 27 April 2007 18:43
To: castle-pro...@googlegroups.com
Subject: Re: ActiveRecord and validation


On 4/27/07, DaveG <d...@albany.co.uk> wrote:
> Nhibernate says that after an exception you shouldn't flush the
> session, but the current ActiveRecord code does in both
> ActiveRecordBase and in AbstractScope.

You mean AR knows an exception happened and invokes Flush anyway?

Email disclaimer:
The information contained in this e-mail is confidential and may be legally privileged. If you are not the intended recipient, please do not read, copy, disclose or otherwise use it. Please notify the sender of the delivery error by return e-mail and delete it and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, or error free. Any views or opinions expressed in this e-mail are those of the author only and Albany Software Limited does not accept any liability for its contents, errors or omissions. Registered in England & Wales No: 2366012

Hamilton Verissimo

unread,
Apr 30, 2007, 7:55:20 AM4/30/07
to castle-pro...@googlegroups.com
Can you show me where that happens?


--
Cheers,
hamilton verissimo
ham...@castlestronghold.com
http://www.castlestronghold.com/

David N. Godfrey

unread,
Apr 30, 2007, 8:05:34 AM4/30/07
to castle-pro...@googlegroups.com

Most of the functions in ActiveRecordBase (InternalSave for example).
The finally clause calls "holder.ReleaseSession()" which calls
"session.Flush" if there is no scope so this gets run even if there is
an exception.

If the session is in a scope the flush isn't done here but the scope
still flushes later.

Hamilton Verissimo

unread,
Apr 30, 2007, 8:12:31 AM4/30/07
to castle-pro...@googlegroups.com
Ok, but this is more a side effect. It depends on the behavior of the
Scope in place. It's not essentially wrong.

What we could do is, on the catch, notify the scope that an error
occurred, so it might decide what to do (flush it or not). As
NHibernate does not cooperate on informing us about exceptions that
cause the session to be stalled, we might have to find a work around.

David N. Godfrey

unread,
Apr 30, 2007, 12:41:23 PM4/30/07
to castle-pro...@googlegroups.com
Does this mean that we need to wrap a currently non-scoped session with
some sort of scope so we can handle the exceptions in the same way? Or
do you see the SessionFactory handling it directly. I suppose it could
maintain a list of sessions with exceptions and decide whether to flush
or not when ReleaseSession is called.

Do you want to see what I've done so far? If so what's the best way to
send a work in progress? Does Google Groups cope with attachments?

Dave.


-----Original Message-----
From: castle-pro...@googlegroups.com
[mailto:castle-pro...@googlegroups.com] On Behalf Of Hamilton
Verissimo
Sent: 30 April 2007 13:13
To: castle-pro...@googlegroups.com
Subject: Re: ActiveRecord and validation

Ok, but this is more a side effect. It depends on the behavior of the
Scope in place. It's not essentially wrong.

What we could do is, on the catch, notify the scope that an error
occurred, so it might decide what to do (flush it or not). As NHibernate
does not cooperate on informing us about exceptions that cause the
session to be stalled, we might have to find a work around.

Email disclaimer:

Hamilton Verissimo

unread,
Apr 30, 2007, 12:45:17 PM4/30/07
to castle-pro...@googlegroups.com
Yep, a patch as a zip file is the best approach.

Thanks

On 4/30/07, David N. Godfrey <d...@albany.co.uk> wrote:
>

David N. Godfrey

unread,
Apr 30, 2007, 12:50:08 PM4/30/07
to castle-pro...@googlegroups.com
OK - here's a patch for anyone to comment on.

It is not finished as it still calls session.clear, and I've only looked
at .net2.

Dave.

-----Original Message-----
From: castle-pro...@googlegroups.com
[mailto:castle-pro...@googlegroups.com] On Behalf Of Hamilton
Verissimo
Sent: 30 April 2007 17:45
To: castle-pro...@googlegroups.com
Subject: Re: ActiveRecord and validation

Yep, a patch as a zip file is the best approach.

Thanks

On 4/30/07, David N. Godfrey <d...@albany.co.uk> wrote:
>
> Does this mean that we need to wrap a currently non-scoped session
> with some sort of scope so we can handle the exceptions in the same
> way? Or do you see the SessionFactory handling it directly. I suppose
> it could maintain a list of sessions with exceptions and decide
> whether to flush or not when ReleaseSession is called.
>
> Do you want to see what I've done so far? If so what's the best way to

> send a work in progress? Does Google Groups cope with attachments?
>
> Dave.
>

ActiveRecordValidation.zip

Hamilton Verissimo

unread,
May 6, 2007, 9:39:49 PM5/6/07
to castle-pro...@googlegroups.com
David, I got this message from svn

"The file ActiveRecord\Castle.ActiveRecord.Tests\Validators\ValidatorTestCase.cs
was found twice!?!
This usually happens if you applied a patchfile to the
wrong folder!"

Can you, well, check again the patch? Thanks

About the rest of the patch, it looks neat. I'm not sure you need the
ARValidationRegistry, though. We could use the default validation
registry, as long as we have just one instance per AppDomain for best
performance...

Reply all
Reply to author
Forward
0 new messages