<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue May 21 18:48:11 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-2156/DDC-2156.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-2156] [regression] EntityManager::find() doesn&apos;t call custom repository anymore</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2156</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Up to version 2.2 the entity manager would forward calls to &lt;tt&gt;find()&lt;/tt&gt; to the respective repositories. In 2.3 the entity manager handles these calls directly.&lt;/p&gt;

&lt;p&gt;This interferes with custom repositories that have an overridden &lt;tt&gt;find()&lt;/tt&gt; method.&lt;/p&gt;

&lt;p&gt;It&apos;s inconsistent, because &lt;tt&gt;$em-&amp;gt;getRepository(&apos;Foo&apos;)-&amp;gt;find($id)&lt;/tt&gt; may do something different to &lt;tt&gt;$em -&amp;gt;find(&apos;Foo&apos;, $id)&lt;/tt&gt; now.&lt;/p&gt;

&lt;p&gt;Not sure if this is intentional. If it is, it&apos;s missing in the change log and the docs (7.8.1. &quot;Essentially, EntityManager#find() is just a shortcut for the following...&quot;).&lt;/p&gt;

&lt;p&gt;In any case it&apos;s a big BC issue for us:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;We have (generated) repositories for all aggregate roots which override &lt;tt&gt;find()&lt;/tt&gt; to throw (also generated) custom exceptions when an entity isn&apos;t found. We just don&apos;t want all those &lt;tt&gt;null&lt;/tt&gt; checks in the client code, especially as we&apos;d sooner or later forget one somewhere.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;We are using the &lt;tt&gt;$em-&amp;gt;find(&apos;Foo&apos;, $id)&lt;/tt&gt; style everywhere because it&apos;s more concise - it doesn&apos;t seem to make much sense to explicitly fetch the repository when this could be done implicitly.&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
            <key id="14245">DDC-2156</key>
            <summary>[regression] EntityManager::find() doesn&apos;t call custom repository anymore</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="6">Invalid</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="literal">Stan Imbt</reporter>
                        <labels>
                    </labels>
                <created>Mon, 19 Nov 2012 20:33:45 +0000</created>
                <updated>Tue, 27 Nov 2012 21:25:45 +0000</updated>
                    <resolved>Tue, 27 Nov 2012 21:23:04 +0000</resolved>
                            <version>2.3</version>
                                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="19050" author="beberlei" created="Sun, 25 Nov 2012 12:14:33 +0000"  >&lt;p&gt;The problem is, that users changing EntityRepository#find() is actually why we moved the code to EntityManager#find(), because the behavior is required to work this way internally.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=guilhermeblanco&quot; class=&quot;user-hover&quot; rel=&quot;guilhermeblanco&quot;&gt;Guilherme Blanco&lt;/a&gt; Whats your opinion on this BC break?&lt;/p&gt;</comment>
                    <comment id="19064" author="literal" created="Mon, 26 Nov 2012 10:21:09 +0000"  >&lt;p&gt;I don&apos;t quite get it. You have moved the code to protect people from themselves? Like people overriding &quot;find()&quot; with a modified copy of the original &quot;find()&quot;-code which would fail with a new version of Doctrine? Did that really happen a lot?&lt;/p&gt;

&lt;p&gt;I mean, what could be the problem be with an overridden &quot;find()&quot; doing &quot;$entity = parent::find(...); if (!$entity) throw ...; return $entity;&quot;. And this seems like the typical example of why someone would want to override &quot;find()&quot;...&lt;/p&gt;</comment>
                    <comment id="19072" author="ocramius" created="Tue, 27 Nov 2012 20:45:24 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=literal&quot; class=&quot;user-hover&quot; rel=&quot;literal&quot;&gt;Stan Imbt&lt;/a&gt; why were you assuming that the `find` method on the ObjectManager is just a shortcut to the ObjectRepository&apos;s `find`? I think that assumption is wrong.&lt;/p&gt;</comment>
                    <comment id="19073" author="beberlei" created="Tue, 27 Nov 2012 21:23:04 +0000"  >&lt;p&gt;I close this here for the following reasons:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;EntityManager#find() behavior is required to be the one defined by Doctrine&lt;/li&gt;
	&lt;li&gt;Extension Point is EntityRepository#find().&lt;/li&gt;
	&lt;li&gt;EntityManager#find() is not a shortcut for EntityRepository#find().&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;You may work around this in your application by:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Decorating the EntityManager&lt;/li&gt;
	&lt;li&gt;Using the repository instead of the EntityManager&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    <comment id="19074" author="guilhermeblanco" created="Tue, 27 Nov 2012 21:25:45 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=literal&quot; class=&quot;user-hover&quot; rel=&quot;literal&quot;&gt;Stan Imbt&lt;/a&gt; Our point of extension is EntityRepository, not EntityManager.&lt;br/&gt;
So, if you override the EntityRepository, you should also access using EntityRepository. We received many reports of people complaining that Locking was not working, while in fact they have overwritten find() and forgot to add the lock call.&lt;/p&gt;

&lt;p&gt;To fix your problem, I&apos;d suggest you to use composition around EntityManager and create a delegate to EntityRepository on your method find. That would fix your problem.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>