Search code examples
javaeclipselink

What's the default caching behaviour for EclipseLink? and how to enable a L2 cache in-proc?


What's the default caching behaviour for EclipseLink?

I have a multi-threaded Java SE server and create a EntityManager per thread using the ThreadLocal pattern. I would like to able some sort of L2 cache to cache data in the server process. How can i do this?

Thanks


Solution

  • EclipseLink enables its shared L2 cache by default. You do not need to do anything to enable it.

    To disable it see, http://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F

    I would not recommend creating an EntityManager per thread. You should normally create an EntityManager per request, or per transaction, or per session at most. You should have a singleton EntityManagerFactory.