一:查詢緩存的配置
二:單元測試
@org.junit.Test @SuppressWarnings({ "unused", "unchecked" }) public void testQueryCahce(){ Session session = factory.openSession(); session.beginTransaction(); Listlist = (List )session.createQuery("from User").setCacheable(true).list(); List list2 = (List )session.createQuery("from User").setCacheable(true).list(); session.getTransaction().commit(); session.close(); }
Hibernate:
select
user0_.id as id0_,
user0_.group_id as group3_0_,
user0_.name as name0_
from
User user0_
afterClass