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

  • SEARCH
  • Home
  • 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 7683453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:47:48+00:00 2026-05-31T18:47:48+00:00

Doctrine version 2.1 i am persisting a lot of objects, that is why I

  • 0

Doctrine version 2.1

i am persisting a lot of objects, that is why I have to do $this->entityManager->clear() after $this->entityManager->flush(), however it causes a well known error:

Exception: “A new entity was found through the relationship
‘Entities\A#B’ that was not configured to cascade persist operations
for entity: Entities\B@00000000550760cc00000000b0edf71c. Explicitly
persist the new entity or configure cascading persist operations on
the relationship. If you cannot find out which entity causes the
problem implement ‘Entities\B#__toString()’ to get a clue.”

It works for the first flush, but it does not work for all the others. When I comment $this->entityManager->clear();

Here is the code sample:

  if ($flushCounter % 50 == 0) {
    $this->entityManager->flush();
    $this->entityManager->clear();
    //$this->entityManager->detach($B); <- with these two lines commented I tried to fix the error, but it did not work
    //$B = $this->entityManager->find(ENTITY_NAMESPACE . "\B", (int) $B_id);
  }
  $flushCounter++;

I will repeat that commenting out clear() function fixes the issue but i do not want to do that unless there is a better way to manage memory

  • 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-05-31T18:47:50+00:00Added an answer on May 31, 2026 at 6:47 pm

    What was missing is persist on $B after fetching it again.

     if ($flushCounter % 50 == 0) {
        $this->entityManager->flush();
        $this->entityManager->clear();
        $B = $this->entityManager->find(ENTITY_NAMESPACE . "\B", (int) $B_id);
        $this->entityManager->persist($B);
      }
      $flushCounter++;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Zend Framework project using version 1.10.8 with Doctrine 1.2.4.I use Zend_Auth
i have created this query that works OK: $q1 = Doctrine_Query::create() ->from('Usuario u') ->leftJoin('u.AmigoUsuario
i used to have a function defined like this (that is working fine under
I have a table that holds version numbers and I want to read them
Doctrine 2 documentation states that: Removing an association between two entities is similarly straight-forward.
Using Doctrine 2 I want to get some users that are contacts of another
With doctrine if you execute this code $columns = $accountTable->getColumns(); foreach ($columns as $column)
First some basic info: Ubuntu latest version Zend Framewrok 1.9.6 Doctrine 1.2.1 Php unit
I found the console and run it like this: root@valugi-laptop:/var/www/sandbox/hello# php console Symfony version
With Doctrine, I have 2 classes The relation they have is OneToMany/ManyToOne as such:

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.