Announcement Announcement Module
Collapse
No announcement yet.
Not sure, if <tx:advice is applied for my defined method. But traditional way works Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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>
    <aopointcut 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!!!

  • #2
    I hope It may help you a littile bit

    http://www.concretestudy.com/spring/...ransaction.php

    Comment


    • #3
      I have not found the method named storeSendData,should be storeLhrSendData instead?

      Comment

      Working...
      X