关于Hibernate在运行时出现的异常,该如何处置呢?本篇博客就列举了一个在处理一个项目的时候出现的异常,是因为一时的失误,导致半天不能正确运行的问题?
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:620)
at com.ken.hibernate.model.hibernateORMappingTest.saveUserTest(hibernateORMappingTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
原来是:
hibernate.cfg.xml中session-factory里
<!-- Enable Hibernate's automatic session context management
<property name="current_session_context_class">thread</property>
-->
被注释掉了,打开即可。就是这个简单的问题,花费了半天的时间才找到解决方法。