I am trying to write a unit test class which will have to use same query to fetch the results from database two times in same test method. But as Hibernate cache is enabled
According to a guy from the hibenrate team :
The second-level cache has nothing to do with the first-level (session or persistence context) cache. The persistence context/session cache is mandatory for various reasons. In fact, not understanding this crucial part and ignoring it in application architecture is a recipe for disaster. There is no quick solution here, study some documentation.
Source :https://forum.hibernate.org/viewtopic.php?p=2383408
You might use seesion.evict(your object) before retrying the same query.