-
Jun 22nd, 2012, 09:48 AM
#1
Not sure, if <tx:advice is applied for my defined method. But traditional way works
I need your help in transaction management in springs.....
Env -
Spring version 3.0.5, JDK 1.5, AspectJ 1.6, Websphere 6.1
I have defined <tx:advice as follows in my spring bean conf file
<bean id="transactionManager18" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
<property name="dataSource" ref="dataSource18" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager18">
<tx:attributes>
<tx:method name="storeSendData"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop
ointcut id="myCutTx" expression="execution(* sf.consumerrpt.dataaccess.bo.LhrStoreDataAccessBO. *(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="myCutTx"/>
</aop:config>
package sf.consumerrpt.dataaccess.bo;
public class LhrStoreDataAccessBO implements LhrStoreDataAccessBOIface {
private LhrStoreSendDataAndReceiveDataUtilities storeUtil;
private JdbcTemplate jdbcTemplate;
public void storeLhr(LhrStoreDataTO lhrStoreData, JdbcTemplate jdbcTemplate, Map<String, String> appDefaults) throws RuntimeException {
storeUtil = getStoreUtil();
this.jdbcTemplate = jdbcTemplate;
StoreSendDataOutputTO sendDataOutputTo = storeLhrSendData(lhrStoreData, appDefaults);
}
public StoreSendDataOutputTO storeLhrSendData(LhrStoreDataTO lhrStoreData, Map<String, String> callingApp) throws RuntimeException {
StoreSendDataOutputTO sendDataOutputTo = null;
if(lhrStoreData != null && lhrStoreData.getLhrSendData() != null){
LhrSendDataTO lhrSendDataTo = lhrStoreData.getLhrSendData();
sendDataOutputTo = new StoreSendDataOutputTO();
if(lhrSendDataTo.getApplicant() != null) {
AplctInfoDataTO aplctInfoData = storeUtil.getAplctInfoDataTO(lhrSendDataTo.getAppl icant(), prodRqstId);
aplctInfoInsertDao.insertAplctInfo(aplctInfoData, jdbcTemplate);
throw new RuntimeException("For testing rollback throw runtimeException");
}
}
return sendDataOutputTo;
}
}
I dont see, the data in the database being rolled back when i explicitly throw runtime exception, but it works when instead of using AOP, i use myown transaction class extending TransactionCallbackWithoutResult and overiding the doInTransactionWithoutResult method.
Can you please provide guidence in what is required to make it work through aop, as i am not even sure even if my advice is applied.. Help is really appreciated!!!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules