hiberante性能优化-启用二级缓存
参考资料:
hibernate 3.2 帮助文档 19.2节
1.在hibernate的属性文件中配置sessionFactory的属性,
3.使用注解配置实体public List<YP_lb> findAll() throws DataAccessException {String queryString = "from YP_lb";return (List<YP_lb>)hibernateTemplate.execute(new HibernateCallback() {public List<YP_lb> doInHibernate(Session session) throws HibernateException,SQLException {Query query=session.createQuery("from YP_lb lb");//启用查询缓存query.setCacheable(true);List<YP_lb> lb=query.list();return lb;}});}