On Wed, Jun 10, 2009 at 6:43 PM, Jan Limpens <[email protected]> wrote:

>
> > Catching all exceptions will make the transaction try to commit.
>
> So the only way to stop a transaction from committing would be to
> actively throw an exception and present it to the user as a rescue? I
> thought, the transaction would have been rolled back, before the
> exception was thrown to me.
> I am quite in a bit of trouble, if this is as you say...
>

Just delegate your transaction management to other object other than your
controller; something like this:

public class XyzController : BaseController
{
    private readonly IService service;

    public XyzController(IService service)
    {
        this.service = service;
    }

    public void Index()
    {
        try
        {
            service.DoSomething();
        }
        catch (SomeException ex)
        {
            // handle exception
        }
    }
}

[Transactional]
public class Service : IService
{
     [Transaction(TransactionMode.Require)]
     public void DoSomething()
     {
         ....
     }
}

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