Suppose that we have a businessLogic() method that does 2 things: write some information in a local cache and save the same information in the DB using JDBC so that the contents of the cache and the DB are always the same.
I know we can use Spring's JDBC Datasource Transaction Manager to automatically rollback the DB in case of exception. However, how can we define a custom transaction manager that also rollbacks the content of the cache in this case, so that the contents of the cache and the DB are always in sync?
I'm sure you could create a custom transaction manager in Spring.
But. When you're dealing with objects in two different systems, that's usually something you'd use an XA transaction manager for.
However. When you're working with a persistence system like Spring Data/Hibernate JPA, I would expect that rolling back a transaction would also roll back the persistence system's cache automatically. Assuming that in fact, the internal working objects are even cached before the transaction is formally committed.
Are you sure you're not worrying about things you don't need to worry about?
Being persecuted doesn't in any way prove your righteousness or your beliefs. Many people get persecuted because they are repugnant or annoying. Or just because they can be.
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
professionally read, modify and write PDF files from Java