Transactions In MongoDB

java, mongodb, spring, transactions

Solution

Multi-document ACID transactions are now supported in MongoDB 4.0! See https://www.mongodb.com/blog/post/mongodb-multi-document-acid-transactions-general-availability

Problem

I am using a NoSQL database MongoDB with Java and Spring Data. I am aware that MongoDB only supports transactions for a single document. I am using Spring Transactions to carry out MongoDB transcations. I am using TransactionTemplate. What should I set in TransactionManager when using TransactionTemplate? EDIT I have something like this: ``` <bean id=”txtTemplateBean” class=”org.springframework.transaction.support.TransactionTemplate”> <property name=”transactionManager” ref=”txnManagerBean”></property> ``` I need to define txnManagerBean to point to something like DataSourceTransactionManager for a MongoDB database.

Original source