I made a Test (see below) to verify your proposition but in fact i couldn't even get a single case where the Querycache is evicted.
However if i have a lot of queries and no changes in a period of time, Querycache will constantly increase. Is there no meachanism to prevent that?
@Test
public void testQueryEviction() throws Exception {
Session session = null;
Transaction transaction = null;
// insert a TestEntity
session = SessionFactoryUtil.getInstance().openSession();
transaction = session.beginTransaction();
TestEntity testEntity = new TestEntity("first");
session.save(testEntity);
transaction.commit();
session.close();
// list all Test entities
session = SessionFactoryUtil.getInstance().openSession();
session.createCriteria(TestEntity.class).setCacheable(true).list();
session.close();
QueryCacheAccessor.printSize(); // should be 1 // Another nasty thing here: I cannot get the right statistics via HazelcastInstance.getMap("org.hibernate.cache.StandardQueryCache") this is why i have my own workaround here
// insert another TestEntity
session = SessionFactoryUtil.getInstance().openSession();
transaction = session.beginTransaction();
TestEntity secondTestEntity = new TestEntity("second");
session.save(secondTestEntity);
transaction.commit();
session.close();
Thread.sleep(5000); // give Hazelcast some time to cleanup cache
QueryCacheAccessor.printSize(); // should be 0 actually is 1
}