首页 > Web开发 > 详细

hibernate常见问题?

时间:2017-05-22 22:53:26      阅读:326      评论:0      收藏:0      [点我收藏+]

1、

  <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

  hibernate4版本<prop key="hibernate.current_session_context_class">thread</prop>---》获取当前会话会导致如下结果:

  异常信息:org.hibernate.HibernateException: save is not valid without active transaction

 

  hibernatenate4版本,取消<prop key="hibernate.current_session_context_class">thread</prop>会导致如下结果:

  异常信息: Already value [org.springframework.orm.hibernate5.SessionHolder@779dfe55] for key

  [org.hibernate.internal.SessionFactoryImpl@502f8b57]  bound to thread [main]

  

  解决:将hibernate版本改为hibernate5版本,hibernate可以直接使用getCurrentSession获取当前会话!

 

 

hibernate常见问题?

原文:http://www.cnblogs.com/xcggdd/p/6891789.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!