What you really need is a Pessimistic Offline Lock
http://martinfowler.com/eaaCatalog/pessimisticOfflineLock.htmlTry googling it for more information.
The LockMode.UPGRADE does not lock the record across transactions. As soon as the transaction ends the Lock is released.
So I do not think this will help you!
I had a similiar functionlaity to implement and I used the following approach.
1. Create a Lock table in the DB with the columns:
* Locked_Resource_Id (can be used as the primary key)
2. Create a LockManager class and implement getLock(Id_to_Lock)
3. Create a Lock DAO class (for the LockManager) to manage the Lock Table (using Hibernate if you wish)
All your getRecords() calls should be routed through the LockManager. If you encounter a record which is locked (Id present in the Lock Table) throw an exception.
Once the record is updated, release the lock by deleting the lock table entry.
In this way you can prohibit concurrent reads.
If you do not want an Application to Lock the records endlessly you may include a logic to override a lock based on the time it was created.
Hope this helps you.