In class shown above insertUser() makes a call to deleteUser(). As per my understanding deleteUser() should have been executed in a new/saparate transaction, as it's annotated as @Transactional(propagation = Propagation.REQUIRES_NEW), but it's not happening that way. Instead deleteUser() is also executing in same transaction as that of insertUser(). Below is the log for this code which shows the same.
If that's correct than what is the use of @Transactional(propagation = Propagation.REQUIRES_NEW) annotation at deleteUser().
How a method will execute in saparate transaction if it's marked with an annotation @Transactional(propagation = Propagation.REQUIRES_NEW).
I am confused, please help me. Please let me know if question is not clear.
Transactions are added via a Proxy. But if one method inside your dao calls another method inside your dao. The call does not go back outside the class to call through the proxy again. So therefore, the second method is called directly from the first method and no Transaction code will be wrapped around the second method.
So imagine you go into a house, and at the door you get something handed to you. You are in the hallway now and you go to the kitchen. To get to the kitchen, you don't go through the front door again, you go directly to the kitchen.