2017年8月28日
摘要: 手动配置事务: @Autowired private SessionFactory sessionFactory; Session session=sessionFactory.openSession(); Transaction tx=null; //先开启一个事务 tx=session.begi 阅读全文
posted @ 2017-08-28 17:19 cyy_13 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 参数绑定: Hibernate中对动态查询参数绑定提供了丰富的支持,那么什么是查询参数动态绑定呢?其实如果我们熟悉传统JDBC编程的话,我们就不难理解查询参数动态绑定,如下代码传统JDBC的参数绑定: PrepareStatement pre=connection.prepare(“select * 阅读全文
posted @ 2017-08-28 16:14 cyy_13 阅读(260) 评论(0) 推荐(0) 编辑
摘要: SQLQuery query = sessionFactory.getCurrentSession().createSQLQuery(hql);用getCurrentSession()执行不了SQL 如果用getCurrentSession()会报错:hibernate4不能转换为hibernate 阅读全文
posted @ 2017-08-28 15:39 cyy_13 阅读(197) 评论(0) 推荐(0) 编辑