Will Hibernate support MongoDB transaction?
MongoDB 4.0 adds support for multi-document ACID transactions. But Hibernate still does not support that, I cannot simply use @Transactional(Grails framework) annotation to add transactional behavior for MongoDB operations. I have to write transactional management code by myself. Does anyone have better solution or any idea about when Hibernate support that? Thank you!
Cited from Hibernate: MongoDB does not support transactions. Only changes applied to the same document are done atomically. A change applied to more than one document will not be applied atomically. This problem is slightly mitigated by the fact that Hibernate OGM queues all changes before applying them during flush time. So the window of time used to write to MongoDB is smaller than what you would have done manually.
We recommend that you still use transaction demarcations with Hibernate OGM to trigger the flush operation transparently (on commit). But do not consider rollback as a possibility, this won’t work.