我整合 ssh2 (applicationContext-actions.xml,applicationContext-beans.xml,applicationContext-common.xml)
在添加时出现如下异常 可不知道到底哪里
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' er from transaction definition.
解决方案 »
- eclipse+tomcat debug启动非常之慢?求答案
- java web的优势是什么?
- 听听大家意见!本人想学Jquery,问问应该看什么版本的.大家最常用的jquery是什么版本,用的人多吗?
- 怎么知道web服务器监听的端口和当前应用的名字?
- struts2当中的ajax的json问题
- 请教,OA系统中经常要用到的问题
- 服务器上报No fonts found.错
- 关于记录集的问题
- 请问这是什么错啊,谢谢!The server encountered an internal error () that prevented it from fulfilling this request.
- 有个问题请大家帮忙想一下,是关于大数据表的查询显示
- JavaMail的问题,大家帮忙看下
- 一个JSP与JS的混合问题
第一次看到这个错,肯定会觉得纳闷,它要你修改session的模式,或者移除readOnly er.但是你从来都没有设置session的模式.
原因:spring2.0里面的OpenSessionInViewFilter的getSession方法中会对session的flushMode设定一个默认为NEVER的值,而这个值在hibernate3.0似乎是不能理解的.
<bean>
<property ref="sessionFactory" />
</bean><tx:advice >
<tx:attributes>
<tx:method propagation="REQUIRED" />
<tx:method propagation="REQUIRED" />
<tx:method read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:advisor pointcut="execution(* cn.xg.service.impl.*.*(..))"
advice-ref="txAdvice" />
</aop:config>
另外你也可以重写OpenSessionInView这个Filter类的getSession方法,加一句this.setFlashMode(FlashMode.AUTO)
把你的配置改一下。 <tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
上面是一中配置方法,你也可以 <tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="delete*" propagation="REQUIRED"/>
</tx:attributes>但是你的方法的命名要规范点。。
上面第2段配置这句改下
<tx:method name="*" propagation="REQUIRED"/>
实在不好意思。。