When doing loadtesting in our application, I noticed that if you use @Transactional and @Cacheable annotations, which hibernate always creates a database transaction. Is there an easy way to prevent this? An easier way to solve this problem in spring is this: class / interfaces
- Servicelayer interface
- A cached annotated class that is just a proxy / redirect to
- Annotation Transaction Deployment Class
What's happening:
Call 1:
- Transaction created.
- class method called
- the result is cached and returned
Call 2:
- Transaction created.
- Caching result is returned
The preferred result should be:
Call 1:
- Transaction created.
- class method called
- the result is cached and returned
Call 2:
- Caching result is returned
user1344117
source share