This is coming from a bit of a Hibernate background, but one of the things we use is Open Session in View.
In this type of scenario, we use a Servlet filter, or a transaction interceptor, that starts a transaction as the web request comes in. When the response is about to be sent to the client, the transaction is committed. It is very easy, very simple, and fundamentally, it works!
There are often initial objections regarding the lenght of the transaction, or the merit of keeping it open for the duration of the request-response cycle. Most of those objections can be alleviated when you actually look at the metrics of the operation.
Multi-tier transactions can make this a bit yucky, but for many applications, this is a very functional practice.
Joined: Jul 13, 2005
Hi Cameron McKenzie,
Thanks for your prompt response.
Do you mean I can write a custom transaction manager using servlet filter, which starts the transaction on first page web request come in and then commit the transaction on the second page response?
I think single transaction scope across multiple independent web requests is very difficult implement. Would you please give me more hints how to implement it? e.g. how to get the same datasource across multiple independent web requests whe the server is using the connection pooling?
Cameron Wallace McKenzie
author and cow tipper
Well, again, I'm coming at it from a Hibernate perspective, so my perspective is skewed a bit towards that type of an implementation. I don't want to lead you down the wrong path.
Some people that are much smarter and much better looking than me have written about it in the following tuotrial. This will answer many of your questions, and at least give you a persective on how the Hibernate community deals with this issue:
Originally posted by Calvin Wong: How to handle transaction across serveral web pages?
Not to change the topic, but are you sure this is the real requirement? Sometimes people want a logical transaction, but not an actual lock. For example, what happens if someone leaves your website while in a transaction?
I need to migrate the client-server based POS (which is using PowerBuilder) to web-based POS.
The old system has many business logics and validations on the database level (plsql), the inventory records is locked when user inputted the invoice, and the invoice was inputted across several screens and committed before printing the invoice.
On the new web system, we want to keep the existing db logics.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com