How do I evict data from the Hibernate first level cache (but not the second level cache)?
posted 3 years ago
I'm using Hibernate 4.1.5.Final, Spring 3.1.1.RELEASE, JUnit 4.8.1 and JPA 2.0. I'm trying to test if my second-level cache is set up properly, but I can't figure out how to hit the second level cache. Does anyone know how I can
1.) Evict an entity from the first level cache or
2.) Create a new session within my entity manager in a single JUnit test?
Here's my DAO that I'm trying to test …
Here's the JUnit test …
I think the assertion is failing because I'm using the same session and so my entity is being cached within the first level cache. I'd like to test hitting the second level cache.