Is the @ Transactional annotation on the called method completely invalid in the self-call in the Spring transaction?

for example

public class ShopServiceImpl{
    
    @Transactional
    public void do1(){
        do2();
    }
    
    @Transactional
    public void do2(){
        ....
    }   
}

as in the code above, when do1 calls do2 (), are the @ Transactional, on do2 () invalid with defined propagation attributes such as PROPAGATION_NOT_SUPPORTED,PROPAGATION_NEVER, or timeout?

May.08,2021

Yes, if you need to add a transaction, you can try to get the proxy object through AopContext.currentProxy () , and then call do2.


has encountered this situation, the practice at that time is to inject its own proxy object, and then use this object to call the method

@Autowired
private ShopServiceImpl impl;

@Transactional
public void do1(){
    impl.do2();
}

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-1e97e77-1697.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-1e97e77-1697.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?