如何获取Session

版权声明:本文为博主原创文章,未经博主允许不得转载。 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();

猜你喜欢

转载自blog.csdn.net/joker8023joker/article/details/78805976