JPAContainerFactory.makeJndi and EntityManager.setProperty

Howdie,

I have implemented EclipseLink filters on my entities, and using the EntityManager.setProperty to dynamically alter what is filtered.

When using JPAContainerFactory.makeJndi it created an EntityManager without these FilterProperties set. And I get error messages, as there properties are required:

Caused by: Exception [EclipseLink-6174] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException Exception Description: No value was provided for the session property [activePersonFilter] . This exception is possible when using additional criteria or tenant discriminator columns without specifying the associated contextual property. These properties must be set through Entity Manager, Entity Manager Factory or persistence unit properties. If using native EclipseLink, these properties should be set directly on the session. Does anyone have a solution for this?

I managed to get around the problem (in most cases) by using jpacontainer.getEntityProvider().getEntityManager().setProperty(etc…); But sometimes this doesn’t work, for example for those JPAContainer that immediately require these properties.