The test started to fail due to the change of the test code - it used to
close the entity manager before triggering the fetch group.
means it's not a regression - to fix the test it should be just rolled
to its previous state (rev. 6213).
The test was altered to expose the
bug, which happened when a fetch group is
triggered on a detached
That bug was fixed as part of work on nested fetch groups (see bug
However this is still happening on
Investigation showed that on WebSphere after the entity
manager is closed the
object is still registered in the entity manager's
unitOfWork (and the uow is
That is caused by fix to Bug
- em.find() hangs up in some situations on
WebSphere apparently caches EntityManagerImpls - instead of
closing them it
calls em.clear and then return to a cache for future
The problem was the timing of the clear call - it came when
Eclipselink has not
yet merged uow (in afterComplete).
Fix for Bug
cured this problem but not allowing em.clear() called
uow is merging to do anything but to clear the cache.
are several drawbacks to this solution:
1) Objects read in by ValueHolders
triggered on detached objects may loose
identity (uow has no cache);
uow is never released - map of clones, etc is held until the uow is
This second point is also the reason for the test
failure - the fetch group
code verifies if the object is registered in the
uow, and if it is assumes that
the object is also present in uow's
But currently on WebSphere using jta after em.close() the object is
registered, but is not in the uow's cache.
solution: if em.clear is called on synchronized uow, and if the
merging (WebSphere's case) then don't clear the cache, but set the
that will cause uow to be released after the merge in afterCompletion
That would cure both problems listed above.