Created
July 26, 2012 17:06
-
-
Save boutell/3183250 to your computer and use it in GitHub Desktop.
Deleting search objects related many-to-one to a given posting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In my Search entity class: | |
/** | |
* @ORM\ManyToOne(targetEntity="Posting", inversedBy="words") | |
* @ORM\JoinColumn(name="posting_id", referencedColumnName="id", onDelete="cascade") | |
*/ | |
protected $posting; | |
// Later, when I want to delete the Search objects for a given Posting entity: | |
foreach ($entity->getWords() as $search) | |
{ | |
$em->persist($search); | |
$em->remove($search); | |
} | |
// This produces: | |
A new entity was found through the relationship 'Duke\DukeListBundle\Entity\Posting#words' that was not configured to cascade persist operations for entity: Duke\DukeListBundle\Entity\Search@000000003fbc63ae000000000717a61e. Explicitly persist the new entity or configure cascading persist operations on the relationship. If you cannot find out which entity causes the problem implement 'Duke\DukeListBundle\Entity\Search#__toString()' to get a clue. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment