On the problem of self-invocation of spring transaction

as follows, funcA calls funcB, so @ Transactional on funcB is invalid
my understanding: funcA is in a transaction, and funcB is an internal part of funcA, so funcB is in the transaction where funcA is located
but this does not seem to be the case, why?

public class MyServiceImpl{

 @Transactional
 funcA(){
    sql_insert(a);
    funcB();
 }

 @Transactional
 funcB(){
    sql_insert(b);
 }
}
Mar.21,2022

this is related to spring's transaction propagation behavior, which you can take a look at.


funcB is in the funcA transaction as an ordinary method. There is no problem


Spring transaction management look at the problem can be solved, say propagation behavior, do not understand Spring


refer to spring documentation

mode is a transaction that is not recognized by self-call under proxy (default), and can only be configured as aspectj


Don't you have to remove the comments from funcA in order to see the difference?

if the caller directly calls funcA,funcB 's spring transaction management does not take effect, the caller directly calls funcB is spring transaction management
the caller and MyServiceImpl's bean are not the same object

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5b30f-45601.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5b30f-45601.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?