Confusion between @Transactional and AOP

2019-03-03 22:49发布

Does @Transactional is replacement for AOP in spring 3. are they same? Can I say @Transactional implements AOP internally ?

2条回答
别忘想泡老子
2楼-- · 2019-03-03 23:11

The @Transactionnal annotation is just a simple way to declare that a method is (or all methods of a class are) transactionnal.

The Spring Framework will use an AOP proxy to intercept calls to the method and manage transaction.

So, we can say that @Transactionnal use AOP internally.

More information here

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-03-03 23:23

What you can say is that Spring uses AOP to add a transactional aspect to bean methods annotated with @Transactional: before executing such a method, it starts a transaction (if necessary), and after the method has been executed, it commits or rollbacks the transaction.

查看更多
登录 后发表回答