Two methods in one transaction

I have a DAO class with the following two methods:

@Transactional
public void save() throws Exception {

}

@Transactional
public void save2() {

}

In the service class, I call these methods as follows:

public void processDAO() {
    dao.save();
    dao.save2();
}

My question is, will these methods be executed as part of the same transaction or in independent transactions, or none of them?

Thanks and best regards,

+4
source share
2 answers

If the processDAO () method or the class of this method or the method / class that is higher in the call stack are also annotated with @Transactional, then they will be executed in one transaction, otherwise in two different transactions.

+4
source

.
Spring , . processDAO methond @Transactional processDAO

+4

All Articles