如果使用getCurrentSession需要在hibernate.cfg.xml文件中进行配置:
如果是本地事务(JDBC事务)
<propertyname="hibernate.current_session_context_class">thread</property>
如果是全局事务(jta事务)
<propertyname="hibernate.current_session_context_class">jtx</property>
如果是本地事务(JDBC事务)
<propertyname="hibernate.current_session_context_class">thread</property>
如果是全局事务(jta事务)
<propertyname="hibernate.current_session_context_class">jtx</property>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/1724534/viewspace-2123457/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/1724534/viewspace-2123457/