max wrote:
You really must do something out of the ordinary since you say you "Loose data" !!?!
Please explain how you have built a webapp that cannot ensure data integrity with standard techniques such as:
- transactions
- optimistic or pessimistic locking
- ...
Here's a very standard scenario, let me know what I'm missing or how the above can help.
We have an object, let's call it an Entry. People can comment on an Entry. We also keep track
of the number of comments on an entry.
Here's what happens:
A request to add a comment comes in. We look up the Entry by it's id. We create the comment,
add it to the Entry's set of comments, update the comment count. This all happens in
a thread associated with an HttpRequest.
Now, when if two (or more) people try to add a comment to the Entry at the same time,
_someone_ has to do some form of synchronization/locking/whatever to ensure that
both comments are added, and the update count is correct.
One way is to serialize the requests. It works, but slows things down.
The other (obvious to me) way is to synchronize the data access on the Entry - but like my
original post explains, this can get very tricky.
What would the "normal" way to do this, where "Hibernate does all the hard work" for me?
Hunter