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?

On Tue, Aug 21, 2012 at 7:04 AM, Tom Ware <tom.ware@xxxxxxxxxx> wrote:
  Note that JPA 2.0 provides an explicit way to clear the cache - emf.getCache().evictAll().

An excellent point, but one that proves a little tricky when EJB enters the picture.

Suppose I'm testing an ejb-jar that makes use of a single persistence unit (call it X).  My integration harness deploys it, and runs its tests.  In between each test I want to clear the cache in effect for X.

To do so, I need to have an EJB that is NOT part of the ejb-jar under test somehow get a handle on an EntityManagerFactory that is nevertheless the one that was created for the persistence unit under test (X).  Once I have that, obviously I can clear X's cache.

So from ejb archive Y I need to get a handle on X's persistence unit in such a way that when I say entityManagerFactory.getCache(), I'm getting X's cache, not Y's.

That was why I was interested in the session name.  Maybe that's still barking up the wrong tree?

Best,
Laird

--
http://about.me/lairdnelson


Back to the top