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 created this query that works OK: $q1 = Doctrine_Query::create() ->from('Usuario u') ->leftJoin('u.AmigoUsuario
With doctrine if you execute this code $columns = $accountTable->getColumns(); foreach ($columns as $column)
I'm new to Doctrine and ActiveRecord. How should I filter a table after it
Im using Doctrine and i dont quite understand this code here: $this->hasColumn('id', 'integer', 8,
First some basic info: Ubuntu latest version Zend Framewrok 1.9.6 Doctrine 1.2.1 Php unit
I'm getting this error on my production environnent: (from prod.log) [2012-01-30 17:00:51] request.CRITICAL: Doctrine\ORM\Mapping\MappingException:
I found the console and run it like this: root@valugi-laptop:/var/www/sandbox/hello# php console Symfony version
I am using Symfony 2.0.10 with Doctrine 2.1 and have rather simple query (see
I'm using Symfony2 version 2.0.5 with the bundled Doctrine ORM solution. Since I changed
Starting with version 2.2 Doctrine has Paginator . There is only one example in

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.