Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: What is the difference between the two Propagation types? #17

Open
pjohnmeyer opened this issue Sep 10, 2024 · 1 comment
Open

Comments

@pjohnmeyer
Copy link

pjohnmeyer commented Sep 10, 2024

In the @Transactional annotation, the code supports two Propagation types: REQUIRED and REQUIRED_NEW. The only difference appears to be that REQUIRED_NEW starts a session, whereas REQUIRED assumes one is already started. The commit log / documentation did not help me understand which one I should use, under what circumstances. Can you help?

Thanks!

@Shivam6033
Copy link

hey @pjohnmeyer
When you create an AsyncSession object, it automatically begins a transaction. This means that any database operations performed within the session will be executed as part of a single, atomic unit.
However if you don't want the transaction to be executed in the same transaction context you can use REQUIRED_NEW.
e.g.
Suppose your transaction invokes multiple transactions and you don't want the complete transaction to roll back even if some of the transaction fails. In such case you can use REQUIRED_NEW for those low priority transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants