spring - Multiple @Transactional annotation over more than 2 methods not working -


i have 2 methods transactions, below

class mytransaction(){  @transactional public void initialtranx(){    string userid = 500;   // user specific activity  updateuserbalance(500);   // check user balance }  @transactional private void updateuserbalance(int userid){  // codes updating balance 400 }  } 

now calling initialtranx() method, method internally calls private method updateuserbalance(userid), balance not getting updated after updateuserbalance method executes. after completing public method(parent method) transaction getting committed.

i need commit second method's transaction, after completing private method itself.

i using mysql db , spring data jpa.

please 1 guide me on this.

  1. @transactional not work on private methods, use public. depending on class proxy strategy, calling method in same class may not trigger transaction either.

  2. jpa not officially support nested transactions. may work spring extent, strange errors can happen.

  3. if want force changes database before transaction committed, can use entitymanager.flush().


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -