Community
Participate
Working Groups
Property (properties) passed to em.setProperty (em.setProperties) doesn't take effect unless there is no active persistence context. Also passing ConnectionPolicy properties to setProperty method will lead to ineffective processing - typically there's more than one ConnectionPolicy property specified and they should be processed all together.
Created attachment 151217 [details] Suggested patch. The patch implements "Entity Manager Properties" part of http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/properties_processing Properties applicable to existing uow applied immediately (they still used to set member variables that used to apply to the new uow). If a propert set that requires a new uow log while there is already existing uow, then the warning is logged and processing is postponed until the new uow is created Setting any of ConnectionPolicy properties causes the cached ConnectionPolicy to be removed - it's re-created when the new uow is created. Property processing done in a map (instaed of big if - else if statement). It's uniform for both setProperty and setProperties and more efficient (especially for setProperty). EntityManager.joinTransaction changed in case no uow exists: in this case only verify whether joining is possible (active jta transaction exists). The change postpones creation of the uow that makes it possible to set properties that require a new uow in case of injected entity manager. The next call to getActivePersistenceContext creates the uow and registeres it with the active transaction (apparently we already - before this change - doing that). The change in EntitymanagerFactory.getServerSession makes sure that emf will never pick up a non server session property set by another createEMF, yet will pick up all the non server session properties specified in puInfo or System properties.
Created attachment 151235 [details] Tests. EntityManagerJUnitTestSuite: added new testConnectionPolicySetProperty, alter testConnectionPolicy to run on the server, too. CacheableModelJunitTest: removed em.clear() in testEMPropertiesOnCommit1 and testEMPropertiesOnCommit2 tests - it's no longer required, CACHE_STORE_MODE property set into entity manager now applied immediately.
Checked into trunk.
Created attachment 151308 [details] Test correction Two correction in EntityManagerJUnitTestSuite.internalTestConnectionPolicy: make sure that if transaction is started then it's always rolled back; closeEntityManager(em) instead of em.close() - the former works on the server, too.
Created attachment 151483 [details] Test correction 2. EntityManager.setProperties method is not defined in JPA 1, the patch cahnges the test that uses this api to run only under JPA 2.0
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink