<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 64,  comments - 9,  trackbacks - 0

    org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started
    最近在寫操作CLOB的過程中總是報(bào)這個異常,數(shù)據(jù)去插入進(jìn)去了.


    先看看SessionFactory.getCurrentSession與openSession的區(qū)別
    1. 如果使用的是getCurrentSession來創(chuàng)建session的話,在commit后,session就自動被關(guān)閉了,
        也就是不用再session.close()了。但是如果使用的是openSession方法創(chuàng)建的session的話,
        那么必須顯示的關(guān)閉session,也就是調(diào)用session.close()方法。這樣commit后,session并沒有關(guān)閉
    /*2. getCurrentSession的使用可以參見hibernate\hibernate-3.2\doc\tutorial\src項(xiàng)目
    3. 使用SessionFactory.getCurrentSession()需要在hibernate.cfg.xml中如下配置:
       * 如果采用jdbc獨(dú)立引用程序配置如下:
        <property name="hibernate.current_session_context_class">thread</property>
       * 如果采用了JTA事務(wù)配置如下
        <property name="hibernate.current_session_context_class">jta</property>*/

    開始用的:

    Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
    Transaction tran=session.beginTransaction();

    好多文章里都說只需在Spring配置<bean id="sessionFactory"...---><property name="hibernateProperties">   中加入 <prop key="hibernate.current_session_context_class">thread</prop>就可以解決,試了沒用.

    修改后的:

    Session session = this.getHibernateTemplate().getSessionFactory().openSession();

    Transaction tran=session.beginTransaction();

    ......

    finally
       {  
        session.close();  
       }

    問題解決

    posted on 2009-09-11 17:06 super_nini 閱讀(9743) 評論(6)  編輯  收藏

    FeedBack:
    # re: 轉(zhuǎn):Could not commit Hibernate 問題,spring 事物 提交前session關(guān)閉問題
    2009-10-28 14:22 | 楚門
    真是太感謝了……
    弄了半天,感覺不盡……  回復(fù)  更多評論
      
    # re: 轉(zhuǎn):Could not commit Hibernate 問題,spring 事物 提交前session關(guān)閉問題
    2010-03-02 17:52 | 王成飛
    好文章,就是沒有理由的頂
    感激不盡....  回復(fù)  更多評論
      
    # re: 轉(zhuǎn):Could not commit Hibernate 問題,spring 事物 提交前session關(guān)閉問題
    2010-03-15 14:46 | jspxcgy007
    好貼必須頂!  回復(fù)  更多評論
      
    # re: 轉(zhuǎn):Could not commit Hibernate 問題,spring 事物 提交前session關(guān)閉問題
    2010-11-09 11:32 | chenj
    頂,樓主真是強(qiáng)啊  回復(fù)  更多評論
      
    # re: 轉(zhuǎn):Could not commit Hibernate 問題,spring 事物 提交前session關(guān)閉問題[未登錄]
    2011-12-02 01:18 | liu
    是對的,解決了 強(qiáng)  回復(fù)  更多評論
      
    # re: 轉(zhuǎn):Could not commit Hibernate 問題,spring 事物 提交前session關(guān)閉問題
    2013-01-24 15:41 | 枷鎖
    贊……………………  回復(fù)  更多評論
      

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    <2013年1月>
    303112345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿

    隨筆檔案

    文章檔案

    相冊

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲伦理一区二区| 亚洲免费在线视频观看| 中文字幕亚洲精品无码| 国产成人无码综合亚洲日韩| 亚洲AV无码一区二三区| 成年人免费视频观看| 9420免费高清在线视频| 日韩精品无码免费专区网站| 男人j进女人p免费视频| 国产精品亚洲а∨无码播放不卡| 亚洲人成网站在线观看播放青青| 西西人体44rt高清亚洲| 夜夜春亚洲嫩草影院| 亚洲欧洲自拍拍偷精品 美利坚 | 四虎影视永久免费观看| 久久久高清免费视频 | 亚洲综合一区二区国产精品| 亚洲色精品vr一区二区三区| 亚洲精品无码激情AV| 亚洲Av无码乱码在线播放| 国产精品va无码免费麻豆 | 亚洲A∨精品一区二区三区下载| 亚洲av成人综合网| 亚洲另类春色国产精品| 亚洲免费中文字幕| 亚洲三级中文字幕| 亚洲宅男精品一区在线观看| 亚洲一卡二卡三卡四卡无卡麻豆| 亚洲国产电影在线观看| 亚洲制服丝袜在线播放| 亚洲ts人妖网站| 亚洲国产日韩视频观看| 亚洲午夜精品久久久久久app | 无码高潮少妇毛多水多水免费| 成人影片麻豆国产影片免费观看| 午夜性色一区二区三区免费不卡视频 | 国产成人免费午夜在线观看| 在线永久看片免费的视频| 无码国产精品一区二区免费式直播 | 182tv免费视视频线路一二三| 永久黄色免费网站|