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
You can use:
session.setCacheMode(CacheMode.IGNORE)
after your:
session.createQuery("from Table") statement.
session.createQuery("from Table")
This will ensure that Hibernate doesn't interact with 2nd level cache for any entity returned by this query.