Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Indicate L2 cache usage via EM property
@Stateless
public class EmployeeManager{
@persistenceContext("emp_PU")
EntityManager em;
public Employee getByID(String id){
em.setProperty("javax.persistence.cache.retrieveMode", CacheRetrieveMode.USE); //look for the employee in the L2 cache first
return em.find(Employee.class, id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment