<!--
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Wed May 22 19:32:59 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+MODM+AND+status+%3D+Reopened+ORDER+BY+priority+DESC&tempMax=1000&field=key&field=summary
-->
<!-- If you wish to do custom client-side styling of RSS, uncomment this:
<?xml-stylesheet href="http://www.doctrine-project.org/jira/styles/jiraxml2html.xsl" type="text/xsl"?>
-->
<rss version="0.92">
    <channel>
        <title>Doctrine Project</title>
        <link>http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+MODM+AND+status+%3D+Reopened+ORDER+BY+priority+DESC</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="1" total="1"/>
                <build-info>
            <version>5.2.7</version>
            <build-number>850</build-number>
            <build-date>21-02-2013</build-date>
        </build-info>
<item>
            <title>[MODM-116] Collection Per Class Inheritance : Documents of a child class referenced in a parent class may be saved to the parent collection</title>
                <link>http://www.doctrine-project.org/jira/browse/MODM-116</link>
                <project id="10044" key="MODM">Doctrine MongoDB ODM</project>
                        <description>&lt;p&gt;Here is my class hierarchy (classes &amp;amp; attributes renamed for a better understanding) :&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
/** @Document @InheritanceType(&quot;COLLECTION_PER_CLASS&quot;) **/
class Parent {
    /** @ReferenceOne(targetDocument=&quot;Child&quot;) **/
    protected $child;
}

/** @Document **/
class Child extends Parent {
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;When doing :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;$parent-&amp;gt;setXXX($value);
$parent-&amp;gt;getChild()-&amp;gt;setXXX($value2)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;the $parent-&amp;gt;getChild() document is saved to the Parent collection.&lt;/p&gt;

&lt;p&gt;It looks like the problems lies in UnitOfWork::executeUpdates :&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
if (get_class($document) == $className || $document instanceof Proxy &amp;amp;&amp;amp; $document instanceof $className) {
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;$child_document is an instance of Proxy (ChildProxy) and also an instance of Parent =&amp;gt; saved using the Parent persister.&lt;/p&gt;

&lt;p&gt;Shouldn&apos;t the test be : get_class($document) == $className || get_class($document) == $className_of_Proxy ?&lt;/p&gt;

&lt;p&gt;As a side note : why &quot;if ($class-&amp;gt;isEmbeddedDocument) &lt;/p&gt;
{ continue; }
&lt;p&gt;&quot; is within the foreach and not a &quot;if ($class-&amp;gt;isEmbeddedDocument) &lt;/p&gt;
{ return; }
&lt;p&gt;&quot; at the beginning of the method ?&lt;/p&gt;</description>
                <environment></environment>
            <key id="12360">MODM-116</key>
            <summary>Collection Per Class Inheritance : Documents of a child class referenced in a parent class may be saved to the parent collection</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/critical.png">Critical</priority>
                    <status id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/reopened.png">Reopened</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="jfbus">JF Bustarret</reporter>
                        <labels>
                    </labels>
                <created>Mon, 7 Feb 2011 04:45:43 +0000</created>
                <updated>Thu, 21 Apr 2011 17:13:51 +0000</updated>
                                    <version>1.0.0BETA3</version>
                                                <component>Document Manager</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="15260" author="jwage" created="Fri, 11 Feb 2011 14:24:04 +0000"  >&lt;p&gt;I added a test for this here and it appears to be passing: &lt;a href=&quot;https://github.com/doctrine/mongodb-odm/commit/3f24d77cc04adc0bb5532333e33826100457c666&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/mongodb-odm/commit/3f24d77cc04adc0bb5532333e33826100457c666&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="15272" author="jfbus" created="Fri, 11 Feb 2011 16:34:02 +0000"  >&lt;p&gt;I&apos;ll try to get more info on the problem and provide a test for it.&lt;/p&gt;</comment>
                    <comment id="15602" author="jfbus" created="Mon, 28 Mar 2011 06:08:02 +0000"  >&lt;p&gt;Here is a new test case :&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
/** @Document
 *  @InheritanceType(&quot;COLLECTION_PER_CLASS&quot;)
 **/
class MODM116Parent
{
    /** @Id */
    private $id;

    /** @String */
    private $name;

    /** @ReferenceOne **/
    private $child;

    public function getId()
    {
        return $this-&amp;gt;id;
    }

    public function getName()
    {
        return $this-&amp;gt;name;
    }

    public function setName($name)
    {
        $this-&amp;gt;name = $name;
    }

    public function getChild()
    {
        return $this-&amp;gt;child;
    }

    public function setChild(MODM116Child $child)
    {
        $this-&amp;gt;child = $child;
    }
}

/** @Document **/
class MODM116Child extends MODM116Parent
{
    
    /** @EmbedMany(targetDocument=&quot;MODM116Embedded&quot;) **/
    protected $embedded;
    
    function addEmbedded($parent) {
        $this-&amp;gt;embedded[] = new MODM116Embedded($parent);
    }
}

/** @EmbeddedDocument **/
class MODM116Embedded {
    
    /** @ReferenceOne(targetDocument=&quot;MODM116Parent&quot;) **/
    protected $parent;
    
    public function __construct($parent) {
        $this-&amp;gt;parent = $parent;
    }
    
}


$parent = new MODM116Parent();
$parent-&amp;gt;setName(&apos;test&apos;);
$parent-&amp;gt;setChild(new MODM116Child());
$dm-&amp;gt;persist($parent-&amp;gt;getChild());
$dm-&amp;gt;persist($parent);
$dm-&amp;gt;flush();
$dm-&amp;gt;clear();

$parent = $dm-&amp;gt;getRepository(get_class($parent))-&amp;gt;findOneBy(array(&apos;name&apos; =&amp;gt; &apos;test&apos;));

$parent-&amp;gt;getChild()-&amp;gt;setName(&apos;ok&apos;);
$parent-&amp;gt;getChild()-&amp;gt;addEmbedded($parent);
$dm-&amp;gt;flush();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="15637" author="jfbus" created="Wed, 30 Mar 2011 02:42:50 +0000"  >&lt;p&gt;Pulled the last version from git. The bug still exists.&lt;/p&gt;</comment>
                    <comment id="15741" author="jfbus" created="Thu, 21 Apr 2011 17:13:51 +0000"  >&lt;p&gt;Up. Any news on a fix ?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>