getNamedQuery « Cache « JPA Q&A





1. cache and getNamedQuery()    forum.hibernate.org

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, ...