MongoDB 和 MySql 事务 [英] MongoDB and MySql Transaction

查看:86
本文介绍了MongoDB 和 MySql 事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要执行多个 MySql 查询和多个 MongoDB 查询.如果其中一个查询的执行失败(SQL 或 Mongo),我必须回滚所有已执行的查询.这可能吗?

I need to execute a multiple MySql Queries and Multiple MongoDB queries. If the execution of one of the queries fails (SQL or Mongo) I must rollback all the executed queries. Is that possible?

推荐答案

您可能想查看 Spring Transactions.这是我所知道的解决方案之一.另一种解决方案可能是手动完成:存储当前文档/行尝试更新它们并在必要时回滚.

You might want to check out Spring Transactions. This is one of the solutions I am aware of. Another solution might be to do it manually: store the current documents/rows try to update them and roll back if necessary.

退后一步,问问自己,拥有两个具有相关事务的 DBMS 是否真的有意义,这可能会有所帮助.我会尽一切努力将相关数据存储在一个 DBMS 中.

It might help to take a step back and ask yourself whether it really makes sense to have two DBMS with dependent transactions. I'd do everything to be able to store the related data in one DBMS.

这篇关于MongoDB 和 MySql 事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆