In EclipseLink 2.5.2, how can I obtain the instance of the org.eclipse.persistence.sessions.Project class that is associated with my existing PersistenceUnit / EntityManagerFactory so that I can call setDefaultQueryResultsCachePolicy?

Thanks.

1

There are 1 best solutions below

1
On

You can get it from Session, and you can get Session from EntityManager.

// EntityManagerImpl is from package org.eclipse.persistence.internal.jpa
Session session = ((EntityManagerImpl) entityManager).getActiveSession();
Project project = session.getProject();