Closed
Description
Xiaolong Zuo opened SPR-13843 and commented
I would like to use @Transactional
to private method.I find a way from springdocs 16.5.9,but it's unavailable.
My spring config file like below:
.....
<bean id="tx" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="tx" mode="aspectj" />
.....
My service class like below:
@Service
public class AdminUsAccountService {
@Autowired
private UsAccountMapper usAccountMapper;
public void out() {
UsAccount usAccount1 = new UsAccount();
usAccount1.setId(1);
usAccount1.setType(1);
usAccountMapper.updateByPrimaryKeySelective(usAccount1);
inner();
}
@Transactional
private void inner() {
UsAccount usAccount2 = new UsAccount();
usAccount2.setId(3);
usAccount2.setType(1);
usAccountMapper.updateByPrimaryKeySelective(usAccount2);
throw new RuntimeException();
}
}
I expect the usAccount1's type is 1 and the usAccount2's type is 0(original value in db is 0),but all the two usAccount's type are 1.
Affects: 4.1.7
Backported to: 4.2.7