<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 18 06:43:53 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-250/DDC-250.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-250] ArrayCollection Key Column @indexBy</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-250</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;To be honest I feel like I saw this mentioned somewhere, but after looking around I couldn&apos;t find it, so I&apos;ll just post this anyway.&lt;/p&gt;

&lt;p&gt;I&apos;d like the ability to set a property as the associative key on ArrayCollections.  This functionality could probably be done in a PostLoad by iterating over the objects, but it seems like ArrayCollection should be able to handle this functionality already, it&apos;s just a matter of modifying the mapper/parser.&lt;/p&gt;

&lt;p&gt;Example:&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-none&quot;&gt;/**
 * @Entity
 */
class Object
{
//... $id column and anything else ...
    /**
     * @OneToMany(targetEntity=&quot;Param&quot;, mappedBy=&quot;object&quot;)
     */
    protected $params;
//...
    public function getParam($name)
    {
         return $this-&amp;gt;params[$name];
    }
}

/**
 * @Entity
 */
class Param
{
    /**
     * @ManyToOne(targetEntity=&quot;Object&quot;)
     * @JoinColumn(name=&quot;object_id&quot;, referencedColumnName=&quot;id&quot;, nullable=&quot;false&quot;)
     */
    protected $object;
    /**
     * @Column(type=&quot;string&quot;)
     */
    protected $name;
    /**
     * @Column(type=&quot;string&quot;)
     */
    protected $value;
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you were able to specify an ArrayCollection key column then you would be able to have functions like getParam without having to loop over the objects in the collection.  Something like:&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-none&quot;&gt; @OneToMany(targetEntity=&quot;Param&quot;, mappedBy=&quot;object&quot;, collectionKey=&quot;name&quot;) &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="10718">DDC-250</key>
            <summary>ArrayCollection Key Column @indexBy</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</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="mridgway">Michael Ridgway</reporter>
                        <labels>
                    </labels>
                <created>Tue, 12 Jan 2010 19:49:22 +0000</created>
                <updated>Thu, 11 Oct 2012 12:34:56 +0000</updated>
                    <resolved>Sat, 5 Feb 2011 05:50:46 +0000</resolved>
                                            <fixVersion>2.1</fixVersion>
                                <component>Mapping Drivers</component>
                        <due></due>
                    <votes>1</votes>
                        <watches>4</watches>
                        <comments>
                    <comment id="12714" author="marijn" created="Mon, 19 Apr 2010 19:06:36 +0000"  >&lt;p&gt;As much as I would like this I doubt it is &lt;del&gt;possible&lt;/del&gt; feasible. Imagine the &lt;tt&gt;name&lt;/tt&gt; column of your &lt;tt&gt;Param&lt;/tt&gt; object not being unique for you your linked &lt;tt&gt;Object&lt;/tt&gt;..? How could the &lt;tt&gt;ArrayCollection&lt;/tt&gt; &lt;em&gt;know&lt;/em&gt; which instance to add to the collection and which one not?&lt;/p&gt;</comment>
                    <comment id="12715" author="mridgway" created="Mon, 19 Apr 2010 19:31:39 +0000"  >&lt;p&gt;You are absolutely correct.  There is no way to ensure the uniqueness of the collection elements.  This is something that would have to be ensured in the domain model and shouldn&apos;t have anything to do with Doctrine.&lt;/p&gt;

&lt;p&gt;It will certainly work to loop through the collection on PostLoad (once &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-54&quot; title=&quot;Trigger postLoad events and callbacks after associations have been initialized&quot;&gt;DDC-54&lt;/a&gt; is implemented).  For now, I just set the keys the first time I call getParam().&lt;/p&gt;

&lt;p&gt;I suppose I should close this (I forgot it was still open).&lt;/p&gt;</comment>
                    <comment id="14540" author="mridgway" created="Wed, 6 Oct 2010 11:51:39 +0000"  >&lt;p&gt;I just noticed that DQL has an INDEX BY keyword to be able to do this during a DQL query.  Is this something that could  then be possible to set in a oneToMany or manyToMany?  It seems like most of the groundwork for being able to do this is already done.&lt;/p&gt;</comment>
                    <comment id="15003" author="beberlei" created="Fri, 24 Dec 2010 04:43:17 +0000"  >&lt;p&gt;Example code:&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;&amp;lt;?php

class Article
{
    /** @Id @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;) @GeneratedValue */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; $id;

    /** @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;)
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; $headline;

    /**
     * @OneToMany(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Translation&quot;&lt;/span&gt;, mappedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;article&quot;&lt;/span&gt;)
     * @IndexBy(&lt;span class=&quot;code-quote&quot;&gt;&quot;language&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; $translations;
}

class Translation
{
    /**
     * @Id @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; $language;

    /**
     * @Id @ManyToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Article&quot;&lt;/span&gt;, inversedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;translations&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; $article;

    /**
     * @Column(type=&lt;span class=&quot;code-quote&quot;&gt;&quot;string&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; $headline;
}


$article = $em-&amp;gt;find(&lt;span class=&quot;code-quote&quot;&gt;&quot;Article&quot;&lt;/span&gt;, 1);
$article-&amp;gt;translations[&lt;span class=&quot;code-quote&quot;&gt;&quot;en&quot;&lt;/span&gt;]-&amp;gt;headlinle;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In this case @IndexBy uses the Translation::$language as key for the collection.&lt;/p&gt;</comment>
                    <comment id="15005" author="beberlei" created="Fri, 24 Dec 2010 04:46:15 +0000"  >&lt;p&gt;Schedule for 2.1&lt;/p&gt;</comment>
                    <comment id="15231" author="beberlei" created="Sat, 5 Feb 2011 05:50:46 +0000"  >&lt;p&gt;This is now in master &lt;a href=&quot;https://github.com/doctrine/doctrine2/commit/7390030854cdb4b775f6f11f83c970ab2705e924&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/commit/7390030854cdb4b775f6f11f83c970ab2705e924&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Syntax is:&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;@ManyToMany(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;OtherEntity&quot;&lt;/span&gt;, indexBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;foreignField&quot;&lt;/span&gt;)
@OneToMany(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;OtherEntity&quot;&lt;/span&gt;, indexBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;foreignField&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&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;&amp;lt;many-to-many index-by=&lt;span class=&quot;code-quote&quot;&gt;&quot;foreignField&quot;&lt;/span&gt; /&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&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;manyToMany:
  indexBy: foreignField
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="18824" author="beberlei" created="Thu, 11 Oct 2012 12:34:56 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-470&amp;#93;&lt;/span&gt; was opened&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/470&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/470&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                <issuelinks>
                        <issuelinktype id="10002">
                <name>Dependency</name>
                                <outwardlinks description="depends on">
                            <issuelink>
            <issuekey id="12359">DDC-1018</issuekey>
        </issuelink>
                    </outwardlinks>
                                            </issuelinktype>
                        <issuelinktype id="10001">
                <name>Reference</name>
                                <outwardlinks description="relates to">
                            <issuelink>
            <issuekey id="10620">DDC-213</issuekey>
        </issuelink>
                    </outwardlinks>
                                            </issuelinktype>
                    </issuelinks>
                <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>