wiflish
          Loving Life! Loving Coding!
          posts - 98,comments - 98,trackbacks - 0
          在web.xml文件中配置OpenSessionInViewFilter

          ????
          <filter>
          ????????
          <filter-name>hibernateFilter</filter-name>
          ????????
          <filter-class>
          ????????????org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
          ????????
          </filter-class>
          ??? </filter>
          在spring的事務配置中:
          <aop:config>
          ????
          <aop:advisor?id="managerTx"?advice-ref="txAdvice"
          ????????pointcut
          ="execution(*?*..service.*Manager.*(..))"?order="2"?/>
          </aop:config>

          <tx:advice?id="txAdvice">
          ????
          <tx:attributes>
          ????????
          <tx:method?name="get*"?read-only="true"?/>
          ????????
          <tx:method?name="find*"?read-only="true"?/>
          ????????
          <tx:method?name="*"?/>
          ????
          </tx:attributes>
          </tx:advice>

          這樣的配置,當在容器中通過action調用service代碼保存對象時,不能成功保存對象,
          同時出現如下類似錯誤:
          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.

          這時修改filter的配置,增加如下代碼:
          ????<filter>
          ????????
          <filter-name>hibernateFilter</filter-name>
          ????????
          <filter-class>
          ????????????org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
          ????????
          </filter-class>
          ????????
          <init-param>
          ????????????
          <param-name>singleSession</param-name>
          ????????????
          <param-value>false</param-value>
          ????????
          </init-param>
          ????
          </filter>

          這樣就能成功保存對象了。

          ===================================================================
          額。。。上面那個配置等于不用OpenSessionInViewFilter。。。 沒意義。。

          posted on 2007-04-11 20:33 想飛的魚 閱讀(4769) 評論(3)  編輯  收藏 所屬分類: framework

          FeedBack:
          # re: 關于OpenSessionInViewFilter的配置
          2007-04-13 17:04 | shydow
          這等于沒有使用open session in view  回復  更多評論
            
          # re: 關于OpenSessionInViewFilter的配置
          2008-08-21 16:00 | neo
          這種貼也來發,根本沒有搞清發生問題的原因是什么,你是繞過了問題,但是又遇上了一個新問題,就如樓上所說  回復  更多評論
            
          # re: 關于OpenSessionInViewFilter的配置
          2009-04-28 16:57 | 11
          確實,問題是一個接一個的來,
          Connection is read-only. Queries leading to data modification are not allowed  回復  更多評論
            
          主站蜘蛛池模板: 鄂伦春自治旗| 青铜峡市| 镇原县| 永德县| 盐津县| 无锡市| 丹棱县| 五寨县| 无为县| 榆社县| 安达市| 遂昌县| 新泰市| 永安市| 池州市| 辽源市| 连云港市| 萝北县| 陈巴尔虎旗| 贵溪市| 宜昌市| 吴江市| 新闻| 临高县| 黎川县| 长治市| 铜川市| 岳阳市| 开鲁县| 汕头市| 胶南市| 通道| 上犹县| 周至县| 健康| 双辽市| 长子县| 房山区| 集安市| 安国市| 江源县|