<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sun May 19 16:33:40 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-1268/DDC-1268.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-1268] generate:entities creates bad method names with OneToMany</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1268</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Hi. I noticed a minor bug in the &lt;b&gt;generate:entities&lt;/b&gt; console task. I&apos;ve got a &lt;b&gt;Region&lt;/b&gt; entity that had the following property:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/**
 * @ORM\OneToMany(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;District&quot;&lt;/span&gt;, mappedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;region&quot;&lt;/span&gt;)
 */
&lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $districts;

&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function __construct()
{
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;districts = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; ArrayCollection();
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When I ran the &lt;b&gt;generate:entities&lt;/b&gt; task it created the following methods:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/**
 * Add districts
 *
 * @param Fenix\StudyBundle\Entity\District $districts
 */
&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function addDistricts(\Fenix\StudyBundle\Entity\District $districts)
{
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;districts[] = $districts;
}

/**
 * Get districts
 *
 * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; Doctrine\Common\Collections\Collection 
 */
&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getDistricts()
{
    &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;districts;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The second method&apos;s name is correct, but what about &lt;b&gt;addDistricts&lt;/b&gt;? Since it allows me to add a single &lt;b&gt;District&lt;/b&gt; entity it should be as follows:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;/**
 * Add district
 *
 * @param Fenix\StudyBundle\Entity\District $district
 */
&lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function addDistrict(\Fenix\StudyBundle\Entity\District $district)
{
    $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;districts[] = $district;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In other words, the term after &quot;add&quot; (as well as the parameter&apos;s name) should be the entity&apos;s name, not the property&apos;s one.&lt;/p&gt;</description>
                <environment>Ubuntu 11.04, PHP 5.3.5, Symfony 2.0 RC4</environment>
            <key id="12812">DDC-1268</key>
            <summary>generate:entities creates bad method names with OneToMany</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="alessandro1997">Alessandro Desantis</reporter>
                        <labels>
                    </labels>
                <created>Mon, 11 Jul 2011 09:53:55 +0000</created>
                <updated>Tue, 4 Dec 2012 09:22:06 +0000</updated>
                    <resolved>Tue, 12 Jul 2011 21:50:05 +0000</resolved>
                            <version>2.1</version>
                                <fixVersion>2.1.1</fixVersion>
                                <component>Tools</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="16140" author="beberlei" created="Mon, 11 Jul 2011 10:04:43 +0000"  >&lt;p&gt;The problem is that making singular out of a word is not an easy task and i will not try to make this work somehow. The Entity Generator result is a helper, not necessarily generating the final result of a class. This is one case where the Code Generation will not nmake you happy, so just change it.&lt;/p&gt;</comment>
                    <comment id="16141" author="alessandro1997" created="Mon, 11 Jul 2011 11:28:47 +0000"  >&lt;p&gt;Couldn&apos;t you just use the target Entity&apos;s name (and not the property&apos;s one) in the &quot;add&quot; method?&lt;/p&gt;</comment>
                    <comment id="16142" author="beberlei" created="Mon, 11 Jul 2011 11:39:29 +0000"  >&lt;p&gt;The shortname you mean? Yeah that would be an option you are right, i reopen the ticket&lt;/p&gt;</comment>
                    <comment id="16162" author="beberlei" created="Tue, 12 Jul 2011 21:50:05 +0000"  >&lt;p&gt;Fixed.&lt;/p&gt;

&lt;p&gt;This is sort of a BC break for 2.1, however since this is just a tool and generating code i think its acceptable&lt;/p&gt;</comment>
                    <comment id="16165" author="alessandro1997" created="Tue, 12 Jul 2011 23:47:04 +0000"  >&lt;p&gt;Thanks a lot &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                    <comment id="16199" author="matthewmatician" created="Sat, 23 Jul 2011 21:36:05 +0000"  >&lt;p&gt;Another option for a semantic method name would be to use &apos;addTo&apos; as the prefix, as in &apos;addToDistricts&apos;.&lt;/p&gt;

&lt;p&gt;The problem with using the target Entity&apos;s name (instead of the property&apos;s) is that sometimes you need to have multiple properties that map to the same target Entity.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>