>>But in this case I must lock the "user/pk" table instead of
>>"my data" table: where is the difference ?
You do the following:
(Server Code)
try {
locktable.findByUserLock(user,row_to_lock);
return false;
} catch (FinderException e) {
insert(user,row_to_lock); // can only be inserted of not exists
}
Since this happens in one transaction on the server, only one client can get that
lock. (the second client has to wait until this transaction is finished, so
findByUserLock will not result in a finderexception)
If you receive the lock, you can savely read the data, and later, in another
transaction, save the updated data.
Client "Code":
boolean ok = business.insertLock(user,row_to_lock); // only during this function call
client 2 has to wait;
if (ok) { // client 2 will receive a false here
read_for_update();
} else { print("row is locked"); }
... some user processing...
... // NO TRANSACTION OPEN HERE! but we have the lock...
...
on_save: write_update(); removeLock(user,row_to_lock);
The lock-table is only locked during setting the lock (or trying to), but not during
showing and editing the data. In fact, you only have four short transactions during
(1) lock (2) read (3) update (4) release lock.
But since setting the lock happens in a transaction, only one client can get that lock.
You even don't need a stateful session bean here, since you can give the userid with
every call; by no means keep the transaction open during client calls!
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3844211#3844211
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3844211
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user