I need to do the following in my @Transactional Class
- Do changes to data (empty logs field) inside a DAO object and save to PostGresql DB
- Revert the changes and save to ElasticSearch (with the id generated in the same DAO object from first commit return result).
Here is how the code is
emptylogsField(testCaseResponses); //Data modifications
Iterable<TestCaseResponse> result =
PGRepository.saveAll(converter.convertToEntities(testCaseResponses));
PGRepository.flush();
putBackLogs(result); // Data modifications
result = ESRepository.saveAll(result);
The problem is the same data is getting saved in both repositories. The flush() is not working? Please help.