Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.0-ALPHA4
-
Fix Version/s: 2.0-BETA3
-
Component/s: ORM
-
Security Level: All
-
Labels:None
-
Environment:Hideubuntu x86_64
PHP Version 5.3.2-0.dotdeb.2 (/etc/apt/sources.list: deb http://php53.dotdeb.org stable all)
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbHShowubuntu x86_64 PHP Version 5.3.2-0.dotdeb.2 (/etc/apt/sources.list: deb http://php53.dotdeb.org stable all) Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbH
Description
BUG:
the entries in M:N table article_categories toggle
SOLUTION:
extra flush entry at [*]
Code:
—
$article = $em->find('Entity\Blog\Article', 1);
printf("-- %s\n", count($article->getCategories()));
$article->getCategories()->clear();
//$em->flush(); // [*]
foreach(array(4) as $id)$article->getCategories()->add(
$em->getReference('Entity\Blog\Category', $id)
);
$em->flush();
===
Entities:
class Article
{
/**
* @ManyToMany(targetEntity="Entity\Blog\Category", inversedBy="articles")
* @JoinTable(name="article_category",
* joinColumns={@JoinColumn(name="fk_article", referencedColumnName="pk")},
* inverseJoinColumns={@JoinColumn(name="fk_category", referencedColumnName="pk")}
* )
*/
private $categories;
}
class Category
{
/**
* @ManyToMany(targetEntity="Entity\Blog\Article", mappedBy="categories")
*/
private $articles;
}
tried to apply cascade=
{"all"}, but has no effect.
I dont understand this issue, can you please elaborate what exactly is wrong?