users@glassfish.java.net

Re: Cleaning out EclipseLink cache between EJBs

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 2 Dec 2011 10:01:02 -0500

On Fri, Dec 2, 2011 at 9:45 AM, Phillip Ross <phillip.w.g.ross_at_gmail.com>wrote:

> Similarly, any EMF/EMs I create from
> javax.persistence.Persistence appear to be the same ones that are
> injected into the EJBs.
>

I confess I never even thought of that--to create a new EMF using the
Persistence class and rely on the fact that it will just happen to share
the L2 cache with all other EMFs in the container. (Of course you're not
really supposed to, but this is embedded testing, not production.)

I think I'll stick with the MBean code, and that's only because I couldn't
find any documentation on how many L2 caches, EclipseLink sessions and/or
EntityManagerFactories are actually created when you have an arbitrary
number of EJBs under test all injecting @PersistenceContexts into
themselves. With the MBean code as I have it written, I just rely on
EclipseLink to invalidate everything--for any value of "everything" it
wants. :-)

(Also, what value do you pass in for the String parameter required by the
createEntityManagerFactory(String)
call<http://docs.oracle.com/javaee/6/api/javax/persistence/Persistence.html#createEntityManagerFactory%28java.lang.String%29>
?

Thanks for the tip, however!

Best,
Laird

-- 
http://about.me/lairdnelson