Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:20:32+00:00 2026-06-12T07:20:32+00:00

I have been google for a while, not sure whether Spring Data MongoDB supports

  • 0

I have been google for a while, not sure whether Spring Data MongoDB supports for bulk save.

I need to save a collection of documents into mongo as atomic, either all saved or none saved.

Can anyone share a link or some sample code for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:20:34+00:00Added an answer on June 12, 2026 at 7:20 am

    When you do a save through MongoDB Java driver you can only pass a single document to MongoDB.

    When you do an insert, you can pass a single element or you can pass an array of elements. The latter is what will result in a “bulk insert” (i.e. single insert command by client will result in multiple documents being inserted on the server).

    However, since MongoDB does not support a notion of transaction, if one of the inserts fails there is no way to indicate that previously inserted documents should be deleted or rolled back.

    For the purposes of atomicity, each document insert is a separate operation and there is no supported way to make MongoDB either insert all or none.

    If this is something that your application requires there may be other ways to achieve it:
    – change your schema so that these are subdocuments of a single parent document
    (then there is technically only one “insert” of the parent document)
    – write the transaction semantics into your application code
    – use a database which natively supports two phase commit transactions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking around for a while now and I'm not able to
I have been Google-ing and researching for an answer on how to do a
We have been using Google Code SVN to store a school project. As we
I have been browsing through Google for various explanations but I STILL couldn't figure
I have been playing around with Google Apps Script today and I am trying
I have been looking around ocn Google and Stackoverflow but haven't found what I
I have been searching around using Google but I can't find an answer to
I have been all over stackoverflow and all over Google and I cannot seem
I have been looking for a regular expression with Google for an hour or
I have been trying to create a new google custom search engine, but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.