Reputation: 195
While doing loadtesting on our application I noticed that if you use @Transactional and @Cacheable annotions that hibernate always creates a database transaction. Is there an easy way to prevent this? A more eleberate way to solve this within spring is to have following class/interfaces
What happens is the following
Call 1:
Call 2:
The prefered result should be:
Call 1:
Call 2:
Upvotes: 11
Views: 4597
Reputation: 242686
You need to change relative order of @Transactional
and @Cacheable
aspects.
It can be configured using order
attribute of <tx:annotation-driven>
and <cache:annotation-driven>
. See 8.2.4.7 Advice ordering for the meaning of order values.
Upvotes: 13