2007-12-25

Connection is ReadOnly.

关键字: spring 事务
最近在一次项目中.用ajax调用dao的save方法.出现了个Connection is ReadOnly 的异常.查看配置文件
<bean id="txProxyTemplate" lazy-init="true" abstract="true"
		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager">
			<ref bean="transactionManager" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="save*">PROPAGATION_REQUIRED</prop>
				<prop key="del*">PROPAGATION_REQUIRED</prop>
				<prop key="update*">PROPAGATION_REQUIRED</prop>
				<prop key="create*">PROPAGATION_REQUIRED</prop>
				<prop key="send*">PROPAGATION_REQUIRED</prop>
				<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
			</props>
		</property>
	</bean>

发现都没问题.百思不得其解.后来才偶然发现在ajax动作中用到了两个service对象.先是其中一个service的get方法.得到对象.的某些属性.然后在利用另外一个service来完哼save动作.结果一个service是被Transaction托管的.另外一个不是.这才恍然大悟...赶紧在没被托管的service中加上transaction. 问题解决...
评论
发表评论

您还没有登录,请登录后发表评论

lsk
搜索本博客
存档
最新评论