Spring data and mongodb - simple roll back with spring within @Transactional

前端 未结 5 2096
自闭症患者
自闭症患者 2020-12-14 10:43

I have 2 repositories, one for mongodb (DocumentRepository) and the other for hibernate entity (EntityRepository)

I have a simple service:

 @Transact         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-14 11:33

    MongoDB doesn't support transactions (at least not outside the scope of a single document). If you want to roll back changes you will need to handcraft that yourself. There are a few resources out there that describe ways of implementing your own transactions in Mongo if you really need them in certain circumstances. You could take a look at..

    http://docs.mongodb.org/manual/tutorial/perform-two-phase-commits/

    This is just an explanation of a pattern you could use. If you find that you absolutely need transactions in your application, you should consider whether MongoDB is a good fit for your needs.

提交回复
热议问题