karimkhan pathan wrote:Hi Edward,
If the propagation is set to required then
1.If the calling method is already in a transaction it will use the same transaction
2.If the calling method is in a non-transaction scope it will create new transaction .
Correct me if I'm wrong .
Regards,
Karim.
You are absolutely correct.
For the original poster, setting a propogation is about what happens from the outside coming in. Meaning is the caller already in a Transaction or not. In your example line one is the definition of your method, not a line of code that runs. So you call that method and what is inside that method will always run in a Transaction, either by a transaction created by the calling code, or a new transaction created by calling the method if the calling code is not running in a Transaction already.
Example, two classes A and B. A is calling a method on B. B's method is marked at REQUIRED. If A has already started a Transaction, then B will just join that Transaction and run within it. So if A or B causes the transaction to rollback, everything will rollback. If A has not started a Transaction, then the call to B will create a new Transaction and all the code in B will be within the Transaction, but all the code in A is running outside of a transaction.
-------------------B's method is set to REQUIRED
A------------------B
TX----------------Joins A TX
NO TX -----------Starts New TX
Mark