标签:java
@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对象。标签:java
原文地址:http://yjm199.blog.51cto.com/4408395/1684419