Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm setting up a new, JPA+Spring project. What is the difference (for me as a programmer) between:

<tx:annotation-driven transaction-manager="transactionManager" />

and

<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />

in my applicationContext.xml?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
409 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is a huge difference between Proxies and byte code weaven aspects. Proxies can only intercept if the invocation comes from “outer space”, but not if the invocation comes from the object itself (this.transactionalMethod())

This means if you have a Class with two methods, T and B. Method T has a transaction annotation, and method B invokes T by “this.T()”, then the proxy is never invoked (for T) so there is no transaction handling in this case!

If you use AspectJ the transaction handling code is weaven in the byte code of T, and it will be executed no matter if the invocation comes from the object itself or from an other object.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...