首页 > 数据库技术 > 详细

hibernateTemplate获取jdbc数据库连接

时间:2015-08-13 20:19:24      阅读:282      评论:0      收藏:0      [点我收藏+]
	@Test
	public void test(){
		//获取刷新模式
		this.getHibernateTemplate().getSessionFactory().openSession().setCacheMode(cachemode);
		//获取查询条件
		this.getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(class1);
		//获取数据库connection连接
		this.getHibernateTemplate().getSessionFactory().getCurrentSession().connection();
		//获取数据库connection连接sessionFactory 强转为SessionFactoryImplementor获取数据库连接
		((SessionFactoryImplementor)(this.getHibernateTemplate().getSessionFactory())).getConnectionProvider().getConnection();
	}
	
	
	spring封装的hibernateTemplate对象 进行jdbc操作.此处获取的sessionFactory就是hibernate的sessionFactory对象。


hibernateTemplate获取jdbc数据库连接

原文:http://yjm199.blog.51cto.com/4408395/1684419

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!