Doctrine 2 entity cannot be saved with its many-to-many related entities

Posted by user1333185 on Stack Overflow See other posts from Stack Overflow or by user1333185
Published on 2012-04-14T11:25:34Z Indexed on 2012/04/14 11:29 UTC
Read the original article Hit count: 235

Filed under:
|

I'm writing a project in ZF and have many-to-many related accounts and videos entities and I provide the account with the videos collection. When I try to save the account I receive the following error:

A new entity was found through the relationship 'Entities\Account#playlistVideos' that was not configured to cascade persist operations for entity: Entities\Video@000000004d5f02ef00000000196757dc. 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\Video#__toString()' to get a clue.

I found a suggested solution with cascade={"persist"} which should allow videos to be saved together with the account by only specifying $this->em->persist($account) but then I get the error:

Fatal error: method_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Proxies\EntitiesAccountProxy" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in...

The same happens when I try to manually persist videos and account.

Thank you for the help in advance.

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about doctrine2