空間站

          北極心空

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            15 Posts :: 393 Stories :: 160 Comments :: 0 Trackbacks
          一般這個錯誤是事務引起的,如果確定事務沒有問題,還是有這個錯,可以重寫OpenSessionInViewFilter的2個方法

          在myfaces的wiki里提供了OpenSessionInViewFilter的一個子類如下:
          public class OpenSessionInViewFilter extends org.springframework.orm.hibernate3.support.OpenSessionInViewFilter {
                
                  /**
                   * we do a different flushmode than in the codebase
                   * here
                   */
                  protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
                          Session session = SessionFactoryUtils.getSession(sessionFactory, true);
                          session.setFlushMode(FlushMode.COMMIT);
                          return session;
                  }
                  /**
                   * we do an explicit flush here just in case
                   * we do not have an automated flush
                   */
                  protected void closeSession(Session session, SessionFactory factory) {
                          session.flush();
                          super.closeSession(session, factory);
                  }
          }

          posted on 2008-11-12 11:21 蘆葦 閱讀(20087) 評論(4)  編輯  收藏 所屬分類: Hibernate

          Feedback

          # re: 解決Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.問題 2009-08-26 23:37 b
          這樣做不太好吧
            回復  更多評論
            

          # re: 解決Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.問題 2010-06-23 23:11 Eric_jiang
          動不動就重寫?  回復  更多評論
            

          # re: 解決Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.問題 2011-07-20 16:59 地球乞丐
          謝謝,我的問題解決了!  回復  更多評論
            

          # re: 解決Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.問題 2012-02-21 11:34 mona
          @地球乞丐
          你怎么解決的  回復  更多評論
            

          主站蜘蛛池模板: 夹江县| 绥宁县| 宜丰县| 宜君县| 积石山| 郑州市| 静乐县| 房山区| 晋江市| 大姚县| 抚松县| 建瓯市| 武陟县| 罗山县| 西峡县| 咸宁市| 莱阳市| 寿光市| 达拉特旗| 祁门县| 关岭| 外汇| 琼中| 临洮县| 襄樊市| 高淳县| 甘德县| 江达县| 佳木斯市| 西贡区| 古田县| 台北县| 桐庐县| 屏山县| 松溪县| 涡阳县| 镇平县| 驻马店市| 墨竹工卡县| 昔阳县| 定南县|