首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

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

2012-09-09 
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL):Struts has detected an

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

Struts has detected an unhandled exception:

Messages: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.File:org/springframework/orm/hibernate3/HibernateTemplate.javaLine number:1,186

?

问题:只读模式下(FlushMode.NEVER/MANUAL)写操作不被允许:把你的Session改成FlushMode.COMMIT/AUTO或者清除事务定义中的readOnly标记。

?

解决:

  这个错误是事务引起的,调用的方法不在事务中,如下:

<!-- AOP --><aop:config>  <aop:pointcut id="businessService" expression="execution(public * com.carsale.DAO.*.*(..))"/>    <aop:advisor advice-ref="txAdice" pointcut-ref="businessService"/></aop:config><!-- 使用aop/tx命名空间配置事务管理 --><tx:advice id="txAdice" transaction-manager="transactionManager" ><tx:attributes><tx:method name="get*" read-only="true" propagation="REQUIRED"/><tx:method name="*" read-only="false" propagation="REQUIRED"/></tx:attributes></tx:advice><!-- HibernateManager --><bean id="transactionManager" ref="sessionFactory"/></bean><!--模板方法 -->
?

注意这一句:

expression="execution(public * com.carsale.DAO.*.*(..))

如果调用的方法不在这个包中,就会出现以上错误,把包修改一下就可以了。

热点排行