I read the Version Number Pattern in EJB Design Patterns.
What happens in a System where large no.of clients are interacting and doing millions of transactions where in they will be updating data .since in between the updates the version number will change and they will get the message back that the update has been done and then they have to update the data again.
In this scenario the client has to try lot of times before he actually commits the changes.It will waste a lot of time for the client rite?
please can anyone answer my query.
Maybe you are too pesimisti c:).IMHO, updating data occurs much less than selecting data in any application. So, maybe the client will not spent 'a lot of time' trying.
A volume of data writes compared to data reads is not a matter of opinion, it is a flat fact. I don't think it's true that every possible application will read data more than it will write data. As a simple exaple take a counter which is used to assign unique IDs. This data is probably never read without being re-written, and indeed such cases are not suitable for optimistic concurrency management.
If the overhead of write-retries exceeds the gain of avoiding pessimistic locking, go ahead and using a pessimistic locking startegy (either on the DB level or at the App server level, using commit option A).
I've considered the scenario. You are browsing through a list of products and see 10 products in page. On first page maybe you update one. When returning to the list, data shoud be refreshed. That means 20 selects vs 1 update.
Of course, can be operations in which DML operations occur with the same frequancy as selects (either I didn't understand fully the counter sample, and how it should interact with database) BUT I think in most applications with db access will get data more often than modify it.
I also bet that an experienced DBA or application architect will agree with me. If any is reading, please post...
I agree that in many applications there will be more reads than writes. The line I did not agree to was
"IMHO, updating data occurs much less than selecting data in *any* application".
I don't think this is true. The counter example is one where you never read the data without intending to update it (add 1).
Yes, it seems I've posted in hurry.