No session currently bound to execution context

Hibernate出现以下异常:

Exception in thread "main" org.hibernate.HibernateException: No session currently bound to execution context  

      at org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionContext.java:74)  

      at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)  

      at org.hibernate.tutorial.web.EventManager.listEvents(EventManager.java:78)  

      at org.hibernate.tutorial.web.EventManager.main(EventManager.java:20)


解决办法:

在3.3.1中用

<property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>


在3.2中用

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


 

你可能感兴趣的:(No session currently bound to execution context)