On Tue, Sep 27, 2011 at 8:58 PM, Laird Nelson <ljnelson_at_gmail.com> wrote:
> File this one under working theory at the moment.
>
Modified working theory. :-)
What I am seeing is that the effects of one test method's operation on the
> database are visible--through EclipseLink-supplied EntityManagers only, not
> in the database--by other test methods.
This turns out to be due to the well-documented EclipseLink session cache,
which I'm actually fairly comfortable with.
But here's the remaining problem. I would like--somehow, preferably from
"outside" embedded Glassfish, but still in the same VM--to programmatically
invalidate the session cache.
Is there some kind of static EclipseLink method to do this, or an obscure
asadmin command? Perhaps some kind of JMX invocation?
I am aware that I can not use the session cache at all, by making use of the
<property name="eclipselink.cache.shared.default" value="false" />
persistence.xml property. But that turns it off entirely.
I am also aware that on a query by query basis (at least on the server) I
can instruct a query not to use the shared cache. But for a variety of
reasons I don't want to do that.
What I want to do is, well, empty the cache in between my test methods.
Given that (a) the cache can be invalidated and (b) I have an entire
in-memory Glassfish instance at my disposal, it seems like I should be able
to call some static method somewhere to do this, or to at least get a handle
on the current EclipseLink session by rooting around in the Glassfish object
itself (
http://embedded-glassfish.java.net/nonav/apidocs/org/glassfish/embeddable/GlassFish.html
).
Any ideas?
Thanks,
Laird
--
http://about.me/lairdnelson