Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Second level cache lifespan?

Hi Laird,

The 2nd level cache for a persistence uint should cease to exist when the last EntityManagerFactory fir that persistence unit is undeployed.

Note that JPA 2.0 provides an explicit way to clear the cache - emf.getCache().evictAll().

The session name property can be used for finer control of our sessions including our cache. If you create an entity manager factory and provide a session name that is new, you will get a new underlying session (and hence a new cache).

-Tom

On 16/08/2012 9:50 AM, Laird Nelson wrote:
What is the lifespan of the second level cache in a JPA-compliant environment?
  If I undeploy a persistence unit, that will kill off the second level cache
established for that persistence unit, correct?

I am doing some integration testing with embedded GlassFish and experimenting
with parallel JUnit integration tests using Maven SureFire.

I have an instance of embedded GlassFish up, and I deploy and undeploy various
Java EE modules to it.  I am looking to do this in parallel, so that for each
JUnit test I would deploy the app with a new underlying H2-in-memory connection
pool/database (for maximum isolation).  I want to ensure that caching is on
during the test, but does not affect subsequent tests.

I'm assuming that the EclipseLink second level cache lives and dies with the
persistence unit, and doesn't lurk on in the background, zombielike, if that
persistence unit is unloaded?

I've read
http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Caching_Overview,
and noted with some interest the eclipselink.session.name
<http://eclipselink.session.name> property.  Does that in effect control how
many caches there are?

Best,
Laird

--
http://about.me/lairdnelson



_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top