spring+hibernate多线程的事务配置
我在实现web service的异步调用,调用后将返回值写入数据库。开发环境是hibernate+spring,现在问题是新启的线程中无法写数据库。
applicationContext.xml中的关于事务的配置如下:
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="*" propagation="REQUIRED" rollback-for="Throwable" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="engineMethods"
expression="execution(* com.ibm.sapsoa.wsfacade.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="engineMethods" />
</aop:config>
多线程实现如下:
if (asyn) {
thread = new Thread(this);
thread.start();
}
public void run() {
loopCall(requestId,reqstatus);
}
在loopCall中进行循环调用webservice,并将返回值写入数据库的表中。
请教各位,给出一个解决方案。怎么进行配置才能实现在新线程中能进行写数据库操作。