Question

<ehcache>
    <cache name="query.ContactInfoList"
        maxElementsInMemory="200"
        eternal="true"
        overflowToDisk="false"
        timeToIdleSeconds="300"
        timeToLiveSeconds="600"
    />
</ehcache>

public List getContactInfoList(){
    hibernateTemplate.setCacheQueries(true);
    hibernateTemplate.setQueryCacheRegion("query.ContactInfoList");
    List list = hibernateTemplate.find("from AdoContactInfo a where active = 1");
    hibernateTemplate.setCacheQueries(false);
    return list;
}

may i know how to clear/refresh cache for query.ContactInfoList when calling hibernatetemplate saveupdate

Was it helpful?

Solution

hibernateTemplate.getSessionFactory().evictQueries("query.ContactInfoList");

will clear that cache region. You can't manually refresh cached query data; cache region will be re-populated (if enabled) once the query runs again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top