'Spring and hibernate. Transaction to both data sources

In my application I need to perform several calculations on entity A, B, C. Due to entity C having a structure suited better for MongoDB I want to perform and commit transaction for entity A and B to oracle db and then entity C to mongo. However, if for any reason JVM crashed after commiting transaction to entity A, and B and commiting to mongo it will lead to incosistent database state. Is there any solution that I could use? I was thinking about using tempomary file that would be created before commiting to the oracle



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source