I think using the optimistic offline lock approach will be sufficient for
your needs.
There is doc on the OJB site. but basically any update increments a version
number which ojb checks and compares to the version it's about to save and
throws an exception which indicates that there is a concurreny conflict.
You can detect this and tell the user that someone else is editing the same
thing and let them decide how to proceed.
HTH
Jin
----- Original Message -----
From: "Fiona Magner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 06, 2004 5:00 PM
Subject: Concurrency question
Hi there:
I am just beginning to use OJB in a Web application. The particular web
application (when it goes live with OJB) will be required for high
availability. I have a question about a concurrency issue that I have come
across. Consider the following example. Two users, a and b are accessing the
customers table and updating the customers balance.
// 1.User A gets customer record 123 (bean) from database.
Customer has balance of 0
// 2. User B gets customer record 123 (accountbalance = 0)
// 3.User A make changes to bean object using retrieved values
eg. c.setAccountbalance(c.getAccountbalance() + 20.00)
(customer will now have balance of 20)
// 4. User B makes changes to account balance (balance now 20)
// 5. User A sends updates to database (stored balance is now 20)
// 6. User B sends updates to database (stored balance is now 20 ***
should be 40)
Note that steps 1, 3 and 5 actually all happen within the one script (as do
2, 4 and 6) but I have just outlined them as separate steps above for
clarity. As you can see it is possible for two concurrent users to cause
inconsistency in the data. Is it necessary to have a markDirty() step in the
script before applying the changes? Also can you tell me if this markDirty()
will put a lock on the table until the changes are committed? Like I say
this will be a high throughput site and therefore I would like to avoid any
lengthy locks on the tables while updates are being carried out. I hope my
email is clear, if you require any more info please let me know.
Thanks!
Fiona
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]