Gail, I would like to point out one other concern with utilizing refresh(entity, lockOptions) versus using the Session.buildLockRequest()/EntityManager.lock() API calls. When you utilize refresh in conjunction with batch fetching it will refresh the specified entity plus up to the batch size of entities that are still not yet hydrated within the session. Typically this is fine - one trip to the database to hydrate multiple entities from the same table could be considered to aid performance. However, when you perform a refresh with a specified lock against a single entity along with batch fetching it will actually execute a lock against all of those entities. This seems to be undesirable behavior (locking more than was requested) - would that be considered a separate bug? |