版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/joker8023joker/article/details/78805976
在Hibernate中获取Session
1.使用HibernateTemplate的getSessionFactory()方法获取:
HibernateTemplate hibernateTemplate;
Session session;
session = hibernateTemplate.getSessionFactory().openSession();
或者
session = hibernateTemplate.getSessionFactory().getCurrentSession();