解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
2016-09-04 10:07
344 查看
解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker的方法:
错误描述: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.
存在的问题:
只读模式下(FlushMode.NEVER/MANUAL)写操作不被允许:把Session改成FlushMode.COMMIT/AUTO(可以解决)
或者清除事务定义中的readOnly标记(清除readOnly标记有时不管用)
解决方法:
web.xml配置里添加
<!-- OpenSessionInView过滤器 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<!--设置bean的名字,如果为默认的sessionFactory则可以省略-->
<init-param> <!--可以省略-->
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
<!--设置bean的初始化参数,如果为默认的单例默认则可以省略-->
<init-param><!--单例模式,可以省略-->
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<!--解决该问题的关键代码-->
<init-param>
<param-name>flushMode</param-name>
<param-value>AUTO</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
相关文章推荐
- 两种方法解决Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- 报错原因 (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker fr
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definitio
- 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
- [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 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
- 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
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly'
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or rem
- Spring+Hibernate4 发生异常Turn your Session into FlushMode.COMMIT/AUTO...