Community
Participate
Working Groups
Fix for bug 319162 fails for entities that do not use deferred locks The following test case illustrates the problem: public void testFlushClearFindNoCascadedLock(){ Map properties = new HashMap(); EntityManager em = createEntityManager(); beginTransaction(em); Address add = new Address(); add.setCity("London"); em.persist(add); commitTransaction(em); beginTransaction(em); add = em.find(Address.class, add.getID()); add.setCity("Barcelona"); em.flush(); em.clear(); add = em.find(Address.class, add.getID()); commitTransaction(em); try{ assertTrue("Address city was returned from server cache, when it should not have been", add.getCity().equals("Barcelona")); } finally { clearCache(); em.clear(); beginTransaction(em); add = em.find(Address.class, add.getID()); em.remove(add); commitTransaction(em); } } The fix appears to be to partially port the fix for Bug 301599. Namely, this change adds a getFromLocalIdentityMap method to IdentityMapAccessor and some calls to it in our cache checking code. Hopefully these parts of the fix can be backported independantly of the larger fix. Note this issue is addressed by the fixes for bug 301599 in 2.2.x and later. Filing this bug since a backport to 2.1.x may be required.
Note, although the fix is already available in 2.2.x and later, the new regression test should be ported to those streams.
Created attachment 202527 [details] Proposed fix - 2.1.x Attached is the proposed fix for the 2.1 stream. As mentioned above, the fix already exists in all other open streams. Only the test case will be ported to those streams.
Fix backported to 2.1.4 as suggested above. Test checked into all streams. Reviewed by James Sutherland Tested with Core and JPA LRG Added test to EntityManagerJunitTestSuite
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink