Hi. I have a problem with cache of hibernate 4.0.1.Final.
I tried use session clear and evict but not working.
I want not to use cache.
I don't know how but when I don't use session close then the cache is clear.
Today I am doing this for do not use the cache.
This is my method:
Code:
public List<MyClass> getByFilter(MyClass user){
session = HibernateConnectionGoogleCloud.getInstanceGoogleCloud();
List<MyClass> mList = new ArrayList<MyClass>();
mList = null;
try{
List<MyClass> list = new ArrayList<MyClass>();
Criteria criteria = session.createCriteria(MyClass.class);
if(!user.getIdentificador().equals("")){
criteria.add(Restrictions.eq("identificador", user.getIdentificador()));
}
criteria.add(Restrictions.between("data", user.getBeginDate(), user.getEndDate()));
list = criteria.list();
if(list != null && list.size() > 0)
mList = list;
}catch (Exception e) {
e.printStackTrace();
}finally {
//session.close();
}
return mList;
}
session close is commented = no cahce
session close is not commented = with cache