当前位置: 代码迷 >> Web前端 >> 处理懒加载有关问题后出现的有关问题:Write operations are not allowed in read-only mode (FlushMode.NEVE
  详细解决方案

处理懒加载有关问题后出现的有关问题:Write operations are not allowed in read-only mode (FlushMode.NEVE

热度:785   发布时间:2012-11-23 22:54:33.0
处理懒加载问题后出现的问题:Write operations are not allowed in read-only mode (FlushMode.NEVE

进行懒加载处理后增加数据出现的问题: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。

Web.xml配置如下:

<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>?
<filter-mapping>?
??? <filter-name>hibernateFilter</filter-name>?
??? <url-pattern>/*</url-pattern>?
</filter-mapping>?

?

出现上面的情况是因为之前Web.xml中没有这个

<init-param>?
??????? <param-name>singleSession</param-name>?
??????? <param-value>false</param-value>?
?</init-param>

?

?

或者是把false设置为true:

<init-param>?
??????? <param-name>singleSession</param-name>?
??????? <param-value>true</param-value>?
?</init-param>

  相关解决方案