I am trying to retrieve the record CounterVar (id=4, type=1) - see mapping file description below - in one transaction. In the same program, with a different transaction, I am trying to retrieve the record CounterVar (id=1, type=1) in the DbLocked mode. Note that in both cases the type field references the same record. This results in my second transaction getting LockNotGrantedException (writeLockTimeout). When I rollback both transactions and retry the retrieve (in the context of the same process), I observed that the call to QueryResults.size() returns 1, but the call to QueryResults.hasMore() returns false. On further investigation, I found that the call to hasMore() sees the following exception stack trace:
org.exolab.castor.jdo.ObjectNotFoundException: The object of type CounterVar with identity 1 was not found in persistent storage
In looking at the code, I see that LockEngine.load() is actually converting the exception ObjectDeletedWaitingForLockException into ObjectNotFoundException.
I am guessing that this is happening because of the previous (unsuccessful) retrieve.