[英]Transactions In MongoDB
I am using a NoSQL database MongoDB with Java and Spring Data.我正在使用带有 Java 和 Spring Data 的 NoSQL 数据库 MongoDB。 I am aware that MongoDB only supports transactions for a single document.我知道 MongoDB 仅支持单个文档的事务。
I am using Spring Transactions to carry out MongoDB transcations.我正在使用 Spring Transactions 来执行 MongoDB 事务。 I am using TransactionTemplate.我正在使用 TransactionTemplate。 What should I set in TransactionManager when using TransactionTemplate?使用 TransactionTemplate 时,我应该在 TransactionManager 中设置什么?
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.我需要定义 txnManagerBean 以指向 MongoDB 数据库的 DataSourceTransactionManager 之类的东西。
Multi-document ACID transactions are now supported in MongoDB 4.0! MongoDB 4.0 现在支持多文档 ACID 事务! See https://www.mongodb.com/blog/post/mongodb-multi-document-acid-transactions-general-availability见https://www.mongodb.com/blog/post/mongodb-multi-document-acid-transactions-general-availability
MongoDB does support transaction- like semantics using two-phase commits . MongoDB 确实支持使用两阶段提交的事务类语义。
There is also another independent effort to support transactions in mongodb using optimistic locking.还有另一个独立的工作是使用乐观锁定来支持 mongodb 中的事务。
MongoDB doesn't support transactions, it only supports atomic operations. MongoDB 不支持事务,它只支持原子操作。
http://docs.mongodb.org/manual/tutorial/model-data-for-atomic-operations/ http://docs.mongodb.org/manual/tutorial/model-data-for-atomic-operations/
Here is a post from someone who implemented transactions for MongoDB with optimistic locking: https://stackoverflow.com/a/12757751/1173560这是使用乐观锁定为 MongoDB 实现事务的人的帖子: https : //stackoverflow.com/a/12757751/1173560
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.