Given two transaction manager tm1 and tm2, It's unclear that transaction created by tm2 will or not participate in existing transaction created by tm1, according to my investigation, the answer is yes if they share same underlying resource, take DataSourceTransactionManager for example:
@Test
public void test(@Autowired DataSource dataSource) {
DataSourceTransactionManager tm1 = new DataSourceTransactionManager(dataSource);
DataSourceTransactionManager tm2 = new DataSourceTransactionManager(dataSource);
TransactionTemplate tt1 = new TransactionTemplate(tm1);
TransactionTemplate tt2 = new TransactionTemplate(tm2);
tt1.executeWithoutResult(s1 -> {
assertThat(s1.isNewTransaction()).isTrue();
tt2.executeWithoutResult(s2 -> {
assertThat(s2.isNewTransaction()).isFalse();
});
});
}
It would be nice if the reference expand on it and the Javadoc mention it.
Given two transaction manager
tm1andtm2, It's unclear that transaction created bytm2will or not participate in existing transaction created bytm1, according to my investigation, the answer is yes if they share same underlying resource, takeDataSourceTransactionManagerfor example:It would be nice if the reference expand on it and the Javadoc mention it.