Using Object Editions
Use the Object class edition and latestEdition methods to check whether the object in cache is the latest edition of that object and use the resynch method to ensure that you have the latest edition without requiring a lock. (When accessing objects without locking, a process can access an object even when another process is updating that object. The process does not see the updates, but instead views the most recently committed edition of the objects. This applies to persistent and shared transient objects.)
When you resynchronize an object (by using the resynch method), it simply marks the object in local cache as obsolete. The next time the object is referenced, JADE goes to the server node with the edition of the cached object. If it is not the latest edition, the updated object is brought back. If the cached object is already the latest edition (that is, the object has not been updated since it was brought into local cache), nothing is brought back.
As it is inefficient, do not use the latestEdition method to duplicate the edition check that JADE does automatically the next time the object is referenced after a resynch method. (As the resynch method only marks the locally cached object as obsolete; nothing is brought back from the server until the object is next referenced. Therefore, if you never reference the object after a resynchronization, JADE will not go to the server again for that object.)
If you know that you want to resynchronize an object, simply use the resynch method. Let JADE do the edition check for you the next time the object is referenced.
In general, it is better to have an object resynchronize another object rather than have the object resynchronize itself. For example, if you want to resynchronize a myObj object, resynchObject(myObj) is preferable to the myObj.resynch code.
If myObj is not in local cache (it may never have been referenced before or it was in cache but the cache has overflowed), using myObj.resynch will require bringing it into cache because it is the receiver of the resynch method. The object will then immediately be marked as obsolete by the resynchronization, requiring a trip to the server on the next reference (if only to confirm that it is the latest edition).
Using resynchObject(myObj) will do nothing if the myObj object is not in cache because there is no locally cached object to resynchronize. The next time myObj is referenced, it will be brought from the server anyway.
For the greatest efficiency resynchronizing other objects, use the current receiver of the method that you are in; that is, the resynchObject (myObj) example above.