Skip to content

Instantly share code, notes, and snippets.

@andriesss
Created December 7, 2012 14:03
Show Gist options
  • Save andriesss/4233452 to your computer and use it in GitHub Desktop.
Save andriesss/4233452 to your computer and use it in GitHub Desktop.
<?php
$user = new User();
$user->addComment(new Comment('foo'));
$user->addComment(new Comment('baz'));
$user->addComment(new Comment('bar'));
$em->persist($user); // i only want the "user" object to be persisted, not the whole object graph
$em->flush();
@andriesss
Copy link
Author

It results in the error of comment #2

@beberlei
Copy link

beberlei commented Dec 7, 2012

but comment doesnt have identity through a foreign entity, it has its own ID field with auto generated value. You must show the wrong code, you cannot get that error message.

@andriesss
Copy link
Author

I think you've just answered my question. In "the real code", the entity has identity through a foreign entity.

@mghazal
Copy link

mghazal commented May 30, 2014

I have the same problem, did you find a solution to the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment