`
78425665
  • 浏览: 123436 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL):

 
阅读更多
遇到这个情况,我猜:

1、你一定使用的spring+hibernate
2、你一定在applicationContext.xml文件中写了事务配置如下:
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="save*" rollback-for="Exception" />
            <tx:method name="insert*" rollback-for="Exception" />
ollback-for="Exception" />
            <tx:method name="get*" read-only="true"/>
        </tx:attributes>
    </tx:advice>

3、你一定使用了过滤器OpenSessionInViewFilter

但是你一定没在过滤器中加入flushMode参数。

原因是在项目中使用Spring+Hibernate的时候,会开启OpenSessionInViewFilter来阻止延迟加载的错误,但是在我们开启OpenSessionInViewFilter这个过滤器的时候FlushMode就已经被默认设置为了MANUAL,如果FlushMode是MANUAL或NEVEL,在操作过程中 hibernate会将事务设置为readonly,所以在增加、删除或修改操作过程中会出现如下错误,只要在那个filter里面加上这段代码就OK了
	     <init-param>
	     	<param-name>flushMode</param-name>
	     	<param-value>AUTO</param-value>
	     </init-param>
分享到:
评论
2 楼 wellba 2015-10-27  
   完美的解决了问题,谢谢分享
1 楼 u013641752 2015-04-07  
添加上去了,但是结果好像一样的,也是删除不了呢。而且是只有删除的时候不行,保存和修改的时候可以

相关推荐

    使用Spring引起的错误

    使用Spring提供的Open Session In View而引起Write operations are not allowed in read-only mode (FlushMode.NEVER) 错误解决

    springmodules-cache.xsd&springmodules-ehcache.xsd.rar

    xml/ns/javaee":deferred-syntax-allowed-as-literal, "http://java.sun.com/xml/ns/javaee":trim-directive-whitespaces, "http://java.sun.com/xml/ns/javaee":default-content-type, ...

    解决fatal:remote error:You can’t push to git://github.com/username/*.git问题的办法

    解决fatal:remote error:You can’t push to git://github.com/username/*.git问题的办法 今天Git push的时候 fatal:remote error: You can't push to git://github....看来我是没有权限push啊。 解决方法: ...接

    net55-r8168-8.045a-napi.x86_64.rar

    2015-01-16: Version 8.039.01: Changed driver code to not use IP checksum hardware offload (caused various issues with networking in VMs) 2015-01-05: Version 8.039.00: Original version

    webgoat-standalone-7.1-SNAPSHOT-exec.jar

    Prerequisites: Java VM 1.8 Open a command shell/window, browse to where you ...Using the --help option will show the allowed command line arguments. 更多查看: https://github.com/WebGoat/WebGoat

    sciter-sdk-4.0.3.5348

    NOTE: sciter.dlls, sciter.exe and notes.exe Windows executables in SDK are digitally signed now. On MacOS you may need to run SDK executables directly from console as they are not signed too.

    sciter-sdk-4.0.0.7

    NOTE: Windows executables in SDK are not signed so you may encounter security warnings on W8 and W10. On MacOS you may need to run SDK executables directly from console as they are not signed too.

    CentOS 5.4安装手册

    d) 修改/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386/drivers/char/mem.c中的range_is_allowed函数,只要return 1;这句。 e) 执行以下命令 i. cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386...

    golang.org/x下的包集合

    https://golang.org/x/下的相关的包国内无法下载,这个可以直接将解压后的golang.org-master/x目录下到包放到GOPATH目录下的golang.org/x路径下面,执行go install 包名称就行了

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    When True then in ftmPanning mode will be shown only cached image of the initial client area. All parts outside will paints of the TFlexPanel.Brush. When returning from ftmPanning mode the complete ...

    Ethercat-Ighmaster.txt

    to select, ranges are allowed. Examples: '1,3', '5-7,9', '-3'. Default: '-' (all). --force -f Force a command. --quiet -q Output less information. --verbose -v ...

    thymeleaf-extras-springsecurity-3.0-master.zip

    In fact, you are allowed to surround your access expression with ${...} if it makes you feel more comfortable: &lt;div sec:authorize="${hasRole(#vars.expectedRole)}"&gt; This will only be displayed if ...

    net-e1000e-3.1.0.2-glr2.x86_64.rar

    Requires MaintMode Live Install Allowed Live Remove Allowed Stateless Ready Overlay Yes No No Yes No Additional links Related VMware Forum's post Package updated to include missing device IDs 1502...

    go代码-https://leetcode-cn.com/problems/insert-delete-getrandom-o1-duplicates-allowed/comments/ 381. O(1) 时间插入、删除和获取随机元素 - 允许重复

    go代码-https://leetcode-cn.com/problems/insert-delete-getrandom-o1-duplicates-allowed/comments/ 381. O(1) 时间插入、删除和获取随机元素 - 允许重复

    net-tulip-1.1.15-1.x86_64.rar

    Requires MaintMode Live Install Allowed Live Remove Allowed Stateless Ready Overlay Yes No No Yes No Additional links VMware Communities thread about running VMware ESXi inside Hyper-V Build ...

    python实现歌声伴奏分离实验与开发

    We once used the audio lab module, but it would seem that it is a bit more complicated to install (with the benefit that many more file formats are allowed). Usage: The easy way to use these ...

    net51-r8169-6.011.00-2vft.510.0.0.799733.x86_64.rar

    在线封装和离线封装驱动 ... Description ...Adds the blacklisted ESXi 5.1 built-in ...Requires MaintMode Live Install Allowed Live Remove Allowed Stateless Ready Overlay Yes No No Yes No

    wp-o-matic.1.0RC4.zip

    Use the post template feature -located in campaign settings-. For example: {content} &lt;p&gt;&lt;a &gt;Link to the original site&lt;/a&gt;&lt;/p&gt; = Why isn’t the full article showing? = Because the feed you're using ...

Global site tag (gtag.js) - Google Analytics