1

can any body provide some insight here..

I have been having hard time, while getting through spring @Transactional(Propagation Nested)

I have been searching all over net and here, but unable to find any generic example of specific type regarding this..

    @Transactional(required)
    mtdOne(User userObj1, User userObj2)
    {
    someBean.mtdtwo( userObj1);
    someBean.mtdThree(userObj2);

    }

@transactional(nested)
mtdTwo(userObj1)
 {
//calling dao and insert data into DATABASE
daoObj.save(userObj1);
//this data must not be rolled back, 
//  even though exception thrown in next method
}

@transactional(required)
mtdThree(userObj2)
 {
//calling dao second time and insert data into DATABASE
daoObj.save(userObj2);


/////Some Exception thrown here

}

So i want to save methodTwo data into DB, and must not be rolled back even though exception thrown in next method..

I want to achieve this Using Transaction(Nested)

Please give me any suggestions..

user2929
  • 21
  • 6
  • Please read on what nested is and does... It isn't what you think it is. Use `REQUIRES_NEW` to have it execute in a separate transaction. – M. Deinum Apr 19 '16 at 05:41
  • @m-deinum But there is no example that i found regarding, nested transaction.. which succeeds in saving data to some specific point.. and doesnot rollback it, when any exception occurs.. – user2929 Apr 19 '16 at 05:46
  • could you plz tell me how to achieve the same with transaction required new... thanks – user2929 Apr 19 '16 at 05:48
  • Replase `NESTED` with `REQUIRES_NEW`... Put a try/catch around the call to `someBean.mtdtwo` and be done. – M. Deinum Apr 19 '16 at 06:25

0 Answers0