Hi,
The declarative transaction management is not working in batch programs.
In firstBatch.xml file, i have written.
In insertReferenceData method, the referenceDAO and alternateDAO methods are called.Code:<bean id="firstBatchJob" class="com.project.jobs.FirstBatch"> <property name="referenceManager" ref="referenceManager" /> </bean> <bean id="referenceManagerServiceTarget" class="com.project.managerImpl.ReferenceManagerImpl"> <property name="referenceDAO" ref="referenceDAO" /> <property name="alternateDAO" ref="alternateDAO" /> </bean> <bean id="referenceManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref local="txManager"/></property> <property name="target"><ref bean="referenceManagerServiceTarget"/></property> <property name="transactionAttributes"> <props> <prop key="insertReferenceData">PROPAGATION_REQUIRED,-Exception</prop> </props> </property> </bean> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean>
After inserting data during referenceDAO method call if there is any exception during insertion in alternateDAO method, the transaction is not getting rolled back.
The data is present in Table 1, it is not rolled back.
What is the reason? Have i done any mistakes in implementing declarative transaction management? Please help me.
My beans definition is
ThanksCode:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.1.xsd">
Mahesh


Reply With Quote