I will not engage in a discussion again, but just to remember:
nhibernate isn't the only resource managed by the tx. nowadays, it's
pretty common to use it together with msmq (for me at least) and the
proposed solutions doesn't handles situation like these.


Cheers,
Henry Conceição



On Wed, Mar 2, 2011 at 9:48 PM, John Simons <[email protected]> wrote:
> I think I just found it:
> http://github.com/castleproject/Castle.Services.Transaction/pull/1
>
> Is this it?
>
> Cheers
> John
>
> From: John Simons <[email protected]>
> To: "[email protected]"
> <[email protected]>
> Cc:
> Sent: Thursday, 3 March 2011 11:22 AM
> Subject: Re: Readonly transactions - yet again.
>
> Hi Jordan,
>
> I can do the merge.
> Where is the pull request?
>
> Cheers
> John
>
> From: Jordan <[email protected]>
> To: Castle Project Development List <[email protected]>
> Cc:
> Sent: Thursday, 3 March 2011 3:19 AM
> Subject: Readonly transactions - yet again.
>
> Hello all,
>
> Hammett accepted my read only transactions patch but doesn't have the
> time to merge it.
> This is another attempt to demonstrate why it is useful in the hope
> that someone else will do so.
> If you don't want the patch, fair enough, I'll leave you in peace :)
>
>
> If the following three points apply to you then you want this patch:
>
> Do you:
> 1) Use Nhibernate
> 2) Use castle validator and put your validation on your domain
> objects.
> 3) Like to explicitly mark out your transactions.
>
>
> It is point 3 that caused some confusion when I raised this before.
> Some people think that if they are reading
> from a database then they don't need transactions which is not
> necessarily true. Every call to a database is done in a transaction.
> SQL server is usually deployed in auto-commit  mode which means that
> it will start and
> commit a transaction for you if you do not explicitly start one. There
> are 2 reasons why you might not want this:
>
> 1) You want to set the isolation level.
> 2) Performance - If there are 10 selects issued you would end up with
> 10 transactions started / committed by the database.
>
>
> This example code from an ASP.NET MVC app demonstrates the problem
> solved by a read only transaction.
> Here we have 2 transactional service methods: UpdateProduct() and
> GetAllProductTypes().
>
> [AcceptVerbs(HttpVerbs.Post)]
> public ActionResult Update(ProductDTO model)
> {
>     try
>     {
>         productService.UpdateProduct(model); // transaction 1 - rolled back
> if exception thrown
>         return RedirectToRoute("ProductList");
>     }
>     catch (ValidationException e)
>     {
>         ModelState.AddModelErrors(e.ValidationResult);  // copy validation
> errors to ModelState
>         ViewData["productTypes"] = productService.GetAllProductTypes(); //
> read only transaction
>         return View(model);
>         }
> }
>
>
> In the implementation of UpdateProduct the values are copied from the
> ProductDTO onto the the Product domain object. If the domain object
> fails validation a ValidationException is thrown, thereby rolling back
> the transaction. The page is then redisplayed so the user can fix the
> errors, and a second transactional method (GetAllProductTypes) is
> called to retrieve data to display on the page.
>
> However, we have a problem in NHibernate world, because the dirty
> Product object is still in the NHibernate session, and will be
> committed if we don't mark the second transaction as read only.
>
> The work around here is to rely on auto-commit mode and not mark
> GetAllProductTypes() as transactional. This will work most of the
> time, but as I mention above there are reasons why you may not want
> this. Wanting to set the isolation level seems like the most useful to
> me.
>
>
> regards,
> Jordan.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Development List" 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-devel?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Development List" 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-devel?hl=en.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Development List" 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-devel?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

Reply via email to