Community
Participate
Working Groups
create EntityManager with property "PersistenceUnitProperties.QUERY_TIMEOUT", then retrive the property by using em.getProperties(), you will see "javax.persistence.query.timeout=20" is listed there. But the property doesn't take effect on UpdateObjectQuery, as a result the execution of "UPDATE...." as for updating locked relationship for locked entity won't return. Because of the problem, the PessimisticLockingExtendedScopeTestSuite can't be enabled to run.
For the EntityManagerFactory case, I create EntityManagerFactory using the property, then create Entity Manager from that factory, the property doesn't take effect as well, see code: Map<String, Object> prop = new HashMap(); prop.put(PersistenceUnitProperties.QUERY_TIMEOUT, 20); EntityManagerFactory emf = Persistence.createEntityManagerFactory("default", prop); EntityManager em2 = emf.createEntityManager();
As suggested by Gordon, all query hints passed to createEntityManager method (or to setProperty or setProperties methods) should be applied to all the queries run by this entity manager. Note that it would be the user's responsibility to make sure that all the passed hints are compatible with all the queries they run: for instance, setting pessimistic timeout query hint into an entity manager would cause an IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-type-for-query-hint". The hints passed to entity manager would apply to not only the queries created using createQuery or creteNativeQuery method but to core queries internally created and executed by Eclipselink - in this case the update query generated by uow.commit() should has timeout set to 20, too. The same should happen when query hints passed to createEntityManagerFactory method - even if the ServerSession has been already created: the hints then should be applied for all entity managers created by the factory. This could be easily implemented in case the query hint could be set in the session (that's the case with query timeout) and then applied to all the queries run with the session. However if it's not the case (for instance, refresh) - how would you do it? Note that you can't set refresh flag on all descriptors - that would affect all entity managers, not just one. Consider creating "template" queries - that would adhere to all the hints passed to createEM - to be associated with ClientSession, then all the queries created by the ClientSession would be clones of the template ones. BTW this approach would allow (if so desired) to apply the query hints only to the appropriate queries (say, not to apply pessimistic lock timeout hint to template update query).
2.1 Bug scrubbing, deferring to 2.1.1.
After talking with Andrei, this has been changed to an enhancement request and targeted for 2.2.0.
Bug Scrubbing for 2.2.0 -> 2.3.0.
bug scrubbing - this is an enh request
Deferring as enhancement.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink