i am trying to use the cache and the getNamedQuery
public class StatusDAO extends XXXXRdbDAO
{
.........
.........
.........
protected Object findByNamedQuery(String namedQuery) throws HibernateException
{
Session session =null;
try
{
session=getSession();
Query query=getNamedQuery(namedQuery,session);
query.setCacheable(true);
query.setCacheRegion(namedQuery);
return query.uniqueResult();
}
finally
{
closeSession(session); /// in order to use the cache i need to remove this line
}
}
protected Query getNamedQuery(String name, Session s) throws HibernateException {
Query q = s.getNamedQuery(name);
return q;
}
.........
.........
.........
}
i realy want to close the session after ....
every things works fine as long as i don't close the session ....
any idea why? and how to pass this ?
thanks
|