No CurrentSessionContext configured!" 异常解决方案

来源:互联网 发布:可靠性软件招标 编辑:程序博客网 时间:2024/06/06 21:05

针对使用properties文件配置hiernate的写法,使用hibernate.cfg.xml应使用第一种调用方式

或者在hibernate.cfg.xml中加入:

 

<property name="current_session_context_class">thread</property>

 

 

  SessionFactory sessionFactory=HibernateSessionFactory.getSessionFactory();
  Session session1=sessionFactory.getCurrentSession();
  
  Session session2=sessionFactory.getCurrentSession();

原创粉丝点击