异常: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.
直到DaoIpml.java 都是正确的,
DaoIpml.java中的源码
@Override
public void addSourceIndustry(SourceIndustry sourceIndustry) {
this.getHibernateTemplate().saveOrUpdate(sourceIndustry);
}
public void addSourceIndustry(SourceIndustry sourceIndustry) {
this.getHibernateTemplate().saveOrUpdate(sourceIndustry);
}
在使用save()方法 保存数据时,一直无法保存。
火狐浏览器报错:
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.
解决方法:
将createAdmin方法配置到spring的事件中管理,添加了以下的一条配置
<tx:method name="create*" propagation="REQUIRED"/>
具体spring事件配置如下:
<aop:config>
<aop:pointcut id="txServices"
expression="execution(* com.trig.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="txServices" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>