Open pjohnmeyer opened 1 month ago
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.
In the
@Transactional
annotation, the code supports two Propagation types:REQUIRED
andREQUIRED_NEW
. The only difference appears to be thatREQUIRED_NEW
starts a session, whereasREQUIRED
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!