I explain the context:
I implemented the export and import records from two differents Data base in other words a refresh of seven tables. I used JdbcCursorItemReader to perform the select chunked queries because there are over 600000 records for each table and save every chunk with jdbc batch insert on the other DB. The implented idea has been the followed:
REMARK on requirement: All tables must be refreshed in unique transaction, if only a chunk of any table fails rollback
I have created a unique method that purge, export/import to chunk for each table in a unique transaction.
Class with annotation
@Transactional
I need to do the same logic, at the same time, to purge and to populate a cache implemeted with ConcurrentHashMap
In a nutshell:
1) OPEN transaction
1.1) purge table
1.2) purge cache
1.3) read data chunk from DataBase Oracle (1000 records at a time)
1.4) insert data chunk on DataBase Postgresql (1000 records at a time)
1.5) put data chunk in cache (ConcurrentHashMap 1000 records at a time)
2) if there aren't exceptions COMMIT all, otherwise ROLLBACK all for DB but also for
ConcurrentHashMap
3) CLOSE transaction
The question is:
Is Transaction annotation able to apply the logic commit or rollback also ConcurrentHashMap ?
Thanks