1.Unable to construct current session context [](Unable to load class [])
这个问题是session环境无法构建,很明显是hibernate.hbm.xml出现了问题,我仔细看了一下我的配置文件
原来:
<!-- 使用getCurrentSession时添加这个属性 -->
<property name="hibernate.current_session_context_class"></property>这里的没有写值,使用本地事务应该是thread。
改正后:<property name="hibernate.current_session_context_class">thread</property>
注:
使用getCurrentSession()需要在hibernate.cfg.xml文件中加入如下配置:
* 如果使用的是本地事务(jdbc事务)
<property name="hibernate.current_session_context_class">thread</property>
* 如果使用的是全局事务(jta事务)
<property name="hibernate.current_session_context_class">jta</property>