MongoDB 中的事务 [英] Transactions In MongoDB
问题描述
我正在使用带有 Java 和 Spring Data 的 NoSQL 数据库 MongoDB.我知道 MongoDB 只支持单个文档的事务.
I am using a NoSQL database MongoDB with Java and Spring Data. I am aware that MongoDB only supports transactions for a single document.
我正在使用 Spring 事务来执行 MongoDB 事务.我正在使用 TransactionTemplate.使用 TransactionTemplate 时,我应该在 TransactionManager 中设置什么?
I am using Spring Transactions to carry out MongoDB transcations. I am using TransactionTemplate. What should I set in TransactionManager when using TransactionTemplate?
编辑
我有这样的事情:
<bean id="txtTemplateBean" class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="txnManagerBean"></property>
我需要定义 txnManagerBean 以指向 MongoDB 数据库的 DataSourceTransactionManager 之类的东西.
I need to define txnManagerBean to point to something like DataSourceTransactionManager for a MongoDB database.
推荐答案
MongoDB 4.0 现在支持多文档 ACID 事务!请参阅 https://www.mongodb.com/blog/post/mongodb-multi-document-acid-transactions-general-availability
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
这篇关于MongoDB 中的事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!