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 8035789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:24:52+00:00 2026-06-05T02:24:52+00:00

Empirically it seems that flush() is not necessary after findAndUpdate() , I just couldn’t

  • 0

Empirically it seems that flush() is not necessary after findAndUpdate(), I just couldn’t find this explicitly stated anywhere in the Doctrine ODM/MongoDB docs (and I didn’t bother to read much source code).

The findAndModify docs on mongodb.org state

This command can be used to atomically modify a document (at most one) and return it.

And Doctrine MongoDB’s findAndUpdate() uses MongoDB’s findAndModify. So it sounds like the whole thing does indeed happen in one go, so calling flush() on the document manager shouldn’t be necessary.

  • 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-05T02:24:53+00:00Added an answer on June 5, 2026 at 2:24 am

    Flush is only needed for writing changes to managed objects back to Mongo. Anything you do through the query builder interface will be executed directly and bypass UnitOfWork. This is especially true for updates and upserts. In the case of findAndUpdate(), the update should be executed in Mongo immediately, but I believe the object returned might be managed. Any changes to that document afterwards (e.g. via setter methods) would need a flush() if you wanted them written back to Mongo.

    Also, be aware of returnNew() on the query builder, which corresponds to the new option of findAndModify. By default, I believe findAndUpdate() will return the document in its pre-updated state. You may prefer to retrieve the document in its updated state.

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

Sidebar

Related Questions

Empirically, it seems that Python's default list sorter, when passed a list of tuples,
This a VERY open question. Basically, I have a computing application that launches test
I am aware that Dijkstra's algorithm can find the minimum distance between two nodes
[This is an empirical question about the state-of-the-art: I am NOT asking if Java
UPDATE: I recently learned from this question that in the entire discussion below, I
I have read in books and heard at university that methods should not exceed
I realize that what counts as premature optimization has a subjective component, but this
In using .NET asynchronous delegates for the first time, I was surprised to empirically
This is a two part question: Part 1 First, dealing with calculating the entropy
I have a question regarding class design. I want to have a class that

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.