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

Reply via email to