Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM

错误提示:Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove ‘readOnly‘ marker from transaction definition.

我在删除一条数据时出现了以上错误,网上查询的答案基本是说这个错误一般由事务引起的,有可能是项目事务配置文件不正确,但是我删除其它数据并没有出现这个问题,所以不存在项目事务配置文件不正确的问题。

经过逐字逐行的对比代码,发现原来是我在删除方法上忘记了添加Spring注解@Transactional来配置事务。

PS:项目事务配置文件存在问题可查看博客1博客2

时间: 2024-10-08 03:49:16

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM的相关文章

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

最近在配置 Structs, spring 和hibernate整合的问题: 开启OpenSessionInViewFilter来阻止延迟加载的错误的时候抛出了这个异常: org.springframework.dao.InvalidDataAccessApiUsageException错误 但是在我们开启OpenSessionInViewFilter这个过滤器的时候FlushMode就已经被默认设置为了MANUAL! 如果FlushMode是MANUAL或NEVEL,在操作过程中 hibern

spring整合之后运行报什么只读错误。Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

解决办法, 再大dao的实现类上添加注解: @Transactional(readOnly = false ) 不让它只读就行了 spring整合之后运行报什么只读错误.Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction defi

Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnl

org.springframework.dao.InvalidDataAccessApiUsageException: 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. 错误解决办法: <fi

(详解)Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session

昨天发现以前正常的功能报错了,错误日志如下: 报错日志: Hibernate: select taxtypecon0_.ID as ID62_, taxtypecon0_.TAX_TYPE_NAME as TAX2_62_, taxtypecon0_.EXPRESSIONS as EXPRESSI3_62_, taxtypecon0_.CREATE_DATE as CREATE4_62_, taxtypecon0_.CREATED_BY as CREATED5_62_, taxtypecon0_

保存数据报错Write operations are not allowed in read-only mode (FlushMode.MANUAL)

1. 报错信息 org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. at org.sp

hibernate框架学习错误集锦-org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL)

最近学习ssh框架,总是出现这问题,后查证是没有开启事务. 如果采用注解方式,直接在业务层加@Transactional 并引入import org.springframework.transaction.annotation.Transactional; 详细信息,可以参考下面博客: 参考资料:http://blog.csdn.net/longxia1987/article/details/7819242 org.springframework.dao.InvalidDataAccessApi

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

今天在做ssh项目开发的时候遇到一个问题,保存数据的时候报错: Write operations are not allowed in read-only mode (FlushMode.NEVER/ 后参考这篇文章才知道出了什么问题:http://www.aichengxu.com/view/37412 原来在Spring事务管理中save类的方法都没有read-only=true,但是我的方法是add*,所以就出现开头讲的问题,把add*方法改成save*就可以了. <!-- 配置事务策略

ssh整合bug

异常: Org.hibernate.lazyinitializationException:could not initialize proxy –no session 这是延迟加载的一个问题,主要原因是service层在开启事务后经过Dao的查询的对象是代理的对象且没有实际参数,只有在使用时才会帮我初始化对象.此时事务提交后session被销毁,而web端得到的是该代理对象,如果此时去初始化对象时会抛出以上异常,因为该对象此时处于游离态. 解决: 不使用延迟加载 手动将延迟加载初始化 Hibe

hibernate整合spring事务异常

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. 该段错误的原因是在保存或者更新数据的时候事务异常,检查一下service里面的方法名是否符合spring配置文件里面的事务提交规则.