Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
来源:互联网 发布:承德县德鸣大数据小镇 编辑:程序博客网 时间:2024/06/05 00:09
在使用了Spring提供的OpenSessionInViewFilter来在一个请求中保持hibernate的session推迟关闭后,会出现如下报错:
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.
原因:
这是因为Spring默认将一个名为“readOnly”的属性设置成为true,导致只能对数据库进行“读”操作,不允许进行“写”操作。
解决:
由于我使用的是Annotation的方式配置的bean,故需要在DAO层的实现类上加上如下注释即可:
@Transactional(readOnly = false)
对于使用beans.xml文件配置的情况,可自行修改beans.xml文件内容。
0 0
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definitio
- [SSH] Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly'
- 报错原因 (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker fr
- spring出现 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marke问题
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- iOS控件之日历
- HTTP协议 处理流程
- c3p0数据库连接池介绍+实例
- 欢迎使用CSDN-markdown编辑器
- 【SPOJ-PALIN】The Next Palindrome【模拟】
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- 工程中应用到的数字电路mos型和ttl型的门电路使用注意事项
- mssql有趣的注入 - niexinming
- 对List<T> 随机排序
- Poj 2983 Is the Information Reliable?
- android 中向手机端安装apk 的时候报出 INSTALL_FAILED_INSUFFICIENT_STORAGE 错误的解决方法
- hibernate annotation 之mappedBy 与 @JoinColumn区别
- Volley之https相关
- SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'customer' cannot be null