I am having trouble starting / comitting transactions with Rhino UnitOfWork.

I created a MvcTransactionAttribute (a MVC Filter), that on the before
action does:
transaction  =  UnitOfWork.Current.BeginTransaction();

After the action has executed (OnActionExectued):
if (filterContext.Exception == null)
{
  transaction.Commit();
}
else
{
  transaction.Rollback();
}

When viewing through SQL Profiler I see that no transaction has been
performed and none of the deletes that I preformed during the
transaction are sent to the server, and nothing happens on
transaction.Commit(), if I add UnitOfWork.Current.Flush() after the
commit then I see the deletes being performed but not in a
transaction.

On UnitOfWorkApplication_EndRequest I also get this exception:
"Tried to unregister a scope that is not the active one"

I am not sure what I am doing wrong, could it be because I am using
the hybrid web/thread scope
Castle.ActiveRecord.Framework.Scopes.HybridWebThreadScopeInfo.

Anyone else run into this problem?

Regards
Torkel

On Tue, Sep 30, 2008 at 9:36 AM, Gabriel Schenker <[EMAIL PROTECTED]> wrote:
> +1 for ATM
>
> On Tue, Sep 30, 2008 at 9:19 AM, Simone Busoli <[EMAIL PROTECTED]>
> wrote:
>>
>> In rhino there is With.Transaction, but I think Ayende will suggest you to
>> use the ATM.
>>
>> On Tue, Sep 30, 2008 at 8:43 AM, Torkel Ödegaard
>> <[EMAIL PROTECTED]> wrote:
>>>
>>> Oh, that explains it.
>>>
>>> What is the best/easiest way to handle transactions with Rhino
>>> UnitOfWork, I don't want to call UnitOfWork.Current.BeginTransaction()
>>> directly. Is it to use Castle.Services.Transaction and the facility
>>> Castle.AutomaticTransactionManagement?
>>>
>>>
>>> On Tue, Sep 30, 2008 at 12:08 AM, Ayende Rahien <[EMAIL PROTECTED]>
>>> wrote:
>>> > Note that the AR one may be an AR term that translate to NH commit.
>>> >
>>> > On Tue, Sep 30, 2008 at 1:08 AM, Ayende Rahien <[EMAIL PROTECTED]>
>>> > wrote:
>>> >>
>>> >> It should be the same, IIRC
>>> >>
>>> >> On Tue, Sep 30, 2008 at 1:02 AM, Torkel Ödegaard
>>> >> <[EMAIL PROTECTED]> wrote:
>>> >>>
>>> >>> Ok, thanks, that was what I thought.
>>> >>>
>>> >>> Was just a little confused why the NHRepository / UnitOfWork used
>>> >>> FlushMode commit and the active record one used never :)
>>> >>>
>>> >>> On Mon, Sep 29, 2008 at 11:18 PM, Ayende Rahien <[EMAIL PROTECTED]>
>>> >>> wrote:
>>> >>> > This will ensure that you have to commit a transaction to save to
>>> >>> > the
>>> >>> > DB.
>>> >>> > That is important.
>>> >>> >
>>> >>> > On Mon, Sep 29, 2008 at 11:57 PM, Torkel Ödegaard
>>> >>> > <[EMAIL PROTECTED]> wrote:
>>> >>> >>
>>> >>> >> Why is the FlushMode set to Never (in
>>> >>> >> ActiveRecordUnitOfWorkFactory).
>>> >>> >>
>>> >>> >> Changes are never persisted to the database unless you explicitly
>>> >>> >> call
>>> >>> >> UnitOfWork.Current.Flush().
>>> >>> >>
>>> >>> >> Is there a reason for this?
>>> >>> >>
>>> >>> >> Cheers
>>> >>> >> Torkel
>>> >>> >>
>>> >>> >>
>>> >>> >
>>> >>> >
>>> >>> > >
>>> >>> >
>>> >>>
>>> >>>
>>> >>
>>> >
>>> >
>>> > >
>>> >
>>>
>>>
>>
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" 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/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to