In Spring based application, Transaction Manager is responsible for committing or rolling back SQL transactions. My application uses a custom cache for some part of persistent data. This cache is not managed by Spring nor Hibernate.
If a SQL transaction encounters errors and must be rolled back, then cache modifications should be rolled back as well.
My question is, how to register an event listener or callback which will call my cache.evict()
method when Spring Transaction Manager rolls back a transaction?