Announcement Announcement Module
Collapse
No announcement yet.
method and its embed method transaction control Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • method and its embed method transaction control

    methodA() contains methodE(). Both methods use Hibernate DAO to access/update database.

    void methodA(){
    ...
    methodE();
    ..
    }

    My goal is methodA() can commit whatever methodE() failed or sucess.

    I use spring JTA transaction manager in JBOSS.
    I try to use below configuration, but it does not work:
    <prop key="methodE">PROPAGATION_REQUIRES_NEW,-java.lang.Exception</prop>
    <prop key="methodA">PROPAGATION_REQUIRED,-java.lang.Exception</prop>


    How can config JTA transction in spring to acchive my goal? Thanks!

  • #2
    methodA contains methodE. methodA should continue irrespective of what happens in methodE.

    Assuming this is the case you can simply wrap the call to methodE with a try catch block and simply ignore the exception (ie avoid it from affecting methodA). So need for setting any special tx attribute for methodE.

    Comment


    • #3
      As sabarish pointed out, if you want a method to not be transactional just do not mark it as transactional.
      In order to make methodA be independent of methodE, make sure that any mechanism that might trigger a rollback (such as an exception thrown from methodE) is cought so that it doesn't gets propagated and affect the tx wrapping methodA.

      Comment

      Working...
      X