<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sun May 19 11:34:35 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/si/jira.issueviews:issue-xml/DDC-2106/DDC-2106.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Doctrine Project</title>
    <link>http://www.doctrine-project.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.7</version>
        <build-number>850</build-number>
        <build-date>21-02-2013</build-date>
    </build-info>

<item>
            <title>[DDC-2106] Notice trying to match a Criteria referencing a managed entity not yet persisted</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2106</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&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;Undefined index: (...) in Doctrine/ORM/UnitOfWork.php line 2735

#0 doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(2735): Symfony\Component\HttpKernel\Debug\ErrorHandler-&amp;gt;handle(8, &apos;Undefined index...&apos;, &apos;/Users/frosas/S...&apos;, 2735, Array) 
#1 doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(1696): Doctrine\ORM\UnitOfWork-&amp;gt;getEntityIdentifier(Object(MyEntity)) 
#2 doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(1683): Doctrine\ORM\Persisters\BasicEntityPersister-&amp;gt;getIndividualValue(Object(MyEntity)) 
#3 doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(818): Doctrine\ORM\Persisters\BasicEntityPersister-&amp;gt;getValue(Object(MyEntity)) 
#4 doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(786): Doctrine\ORM\Persisters\BasicEntityPersister-&amp;gt;expandCriteriaParameters(Object(Doctrine\Common\Collections\Criteria)) 
#5 doctrine/orm/lib/Doctrine/ORM/PersistentCollection.php(835): Doctrine\ORM\Persisters\BasicEntityPersister-&amp;gt;loadCriteria(Object(Doctrine\Common\Collections\Criteria)) 
#6 (...): Doctrine\ORM\PersistentCollection-&amp;gt;matching(Object(Doctrine\Common\Collections\Criteria)) 
#7 (...)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As a workaround I had to control this case explicitly:&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 ($myEntity-&amp;gt;getId() === null) return null;
$criteria = Criteria::create()-&amp;gt;where(Criteria::expr()-&amp;gt;eq(&apos;field&apos;, $myEntity));
return $this-&amp;gt;collection-&amp;gt;matching($criteria)-&amp;gt;first();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="14173">DDC-2106</key>
            <summary>Notice trying to match a Criteria referencing a managed entity not yet persisted</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="4" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/minor.png">Minor</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="frosas">Francesc Ros&#224;s</reporter>
                        <labels>
                    </labels>
                <created>Mon, 29 Oct 2012 14:56:59 +0000</created>
                <updated>Wed, 1 May 2013 16:47:52 +0000</updated>
                    <resolved>Wed, 1 May 2013 16:47:52 +0000</resolved>
                            <version>2.3</version>
                                <fixVersion>2.4</fixVersion>
                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="19507" author="asm89" created="Sat, 9 Feb 2013 22:39:37 +0000"  >&lt;p&gt;Can you provide us with the mapping of your entities? The code shouldn&apos;t get to the point where it asks for the identifier of the object while the object isn&apos;t persisted yet.&lt;/p&gt;</comment>
                    <comment id="19521" author="frosas" created="Sun, 10 Feb 2013 11:58:46 +0000"  >&lt;p&gt;I&apos;m not sure mapping can help to solve this and is quite a work for me to get it without the client details. Anyway I&apos;ll try to reproduce it in a custom scenario if you require it.&lt;/p&gt;

&lt;p&gt;I&apos;ve been doing some debugging and I got this:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;It still fails with last 2.3.*@stable&lt;/li&gt;
	&lt;li&gt;Entity is persisted before matching(). At UnitOfWork::persistNew(), $this-&amp;gt;entityStates&lt;span class=&quot;error&quot;&gt;&amp;#91;$oid&amp;#93;&lt;/span&gt; is set to self::STATE_MANAGED but $this-&amp;gt;entityIdentifiers is untouched ($idGen-&amp;gt;isPostInsertGenerator() is true)&lt;/li&gt;
	&lt;li&gt;When BasicEntityProvider::getIndividualValue() is called, $value state is STATE_MANAGED but $uow-&amp;gt;getEntityIdentifier() fails because $uow-&amp;gt;entityIdentifiers&lt;span class=&quot;error&quot;&gt;&amp;#91;$oid&amp;#93;&lt;/span&gt; was never set.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Hope it helps.&lt;/p&gt;</comment>
                    <comment id="19522" author="asm89" created="Sun, 10 Feb 2013 12:36:03 +0000"  >&lt;p&gt;If you can create a testcase and send a PR with it that would be very helpful. You can create it and put in in the appropriate class here:&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/tree/master/tests/Doctrine/Tests/ORM/Functional/Ticket&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/tree/master/tests/Doctrine/Tests/ORM/Functional/Ticket&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="19547" author="frosas" created="Sat, 16 Feb 2013 01:52:01 +0000"  >&lt;p&gt;Here you have: &lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/582&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/582&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="20161" author="beberlei" created="Wed, 1 May 2013 16:47:52 +0000"  >&lt;p&gt;Fixed in 2.4&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>