<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 18 22:51:22 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-922/DDC-922.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-922] Persisting an entity with an 1:n collection of related entites fails if the FK ist part of a composite PK</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-922</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;If you got two Entities A and B where A is a sample Entity with a 1:n relation to the Entity B&lt;br/&gt;
and B has a composite PK with the FK (A id) and a custom field like this:&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;EntityA:
  type: entity
  table: entity_a
  repositoryClass: EntityARepository
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    handle:
      type: string
      length: 32
      unique: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
 oneToMany:
    entites_b:
      targetEntity: EntityB
      mappedBy: entity_a
      cascade: [persist]
&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;EntityB:
  type: entity
  table: entity_b
  repositoryClass: EntityBRepository
  id:
    description:
      type: string
      length: 255
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      generator:
        strategy: NONE
    entitiy_a_id:
      type: integer
      length: 11
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      generator:
        strategy: NONE
  fields:
    value:
      type: string
      length: 255
  manyToOne:
    entitiy_a:
      targetEntity: EntitiyA
      inversedBy: entities_b
&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;&lt;span class=&quot;code-object&quot;&gt;Class&lt;/span&gt; EntityA
{
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;
    
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $handle;
    
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $b_coll;
    
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function addB(EntityB $ent) 
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;b_coll-&amp;gt;add($ent);
        $b-&amp;gt;setA($&lt;span class=&quot;code-keyword&quot;&gt;this&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;&lt;span class=&quot;code-object&quot;&gt;Class&lt;/span&gt; EntityB
{
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $description;
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $entity_a_id;
    
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $value;
    
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $entity_a;
    
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setA(EntityA $ent)
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;entity_a = $ent;
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;If you try to persist an object of A holding one or more references to objects of B, the objects get correctly persistet. This means, that every inserted record of B has a correctly filled field &quot;entity_a_id&quot;. The objects of B also have a correct reference to A holding now the new A record with its autoinc id.&lt;br/&gt;
But the object property &quot;entity_a_id&quot; stays empty. This leads to a collection of unusable EntityB objects (in memory), since on another persist of EntityA the values of entity_a_id are still not set correctly but the state is managed which leads to an &quot;update B ... where entity_a_id=0&quot;&lt;br/&gt;
We&apos;ve tried to set the entity_a_id with an event handler on postPersist. On a persist of EntityA the collection entities wanted to update their entity_a_ids from 0 to the correct one.&lt;/p&gt;
</description>
                <environment>Doctrine 2 RC 1 with sfDoctrine2Plugin using ORM, DBAL, Common and Symfony/Component for RC 1</environment>
            <key id="12212">DDC-922</key>
            <summary>Persisting an entity with an 1:n collection of related entites fails if the FK ist part of a composite PK</summary>
                <type id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/subtask_alternate.png">Sub-task</type>
                    <parent id="10344">DDC-117</parent>
                        <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="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="branleb">Florian Zumkeller-Quast</reporter>
                        <labels>
                    </labels>
                <created>Thu, 9 Dec 2010 11:52:36 +0000</created>
                <updated>Sun, 2 Jan 2011 06:05:33 +0000</updated>
                    <resolved>Sun, 2 Jan 2011 06:05:33 +0000</resolved>
                            <version>2.0-RC1</version>
                                <fixVersion>2.1</fixVersion>
                                <component>DQL</component>
                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="14941" author="beberlei" created="Fri, 10 Dec 2010 03:20:44 +0000"  >&lt;p&gt;Fixed formating&lt;/p&gt;</comment>
                    <comment id="14942" author="beberlei" created="Fri, 10 Dec 2010 03:22:35 +0000"  >&lt;p&gt;When dealing with foreign keys as composite keys you are currently forced to make use of the &quot;Assigned Id Generator&quot;.&lt;/p&gt;

&lt;p&gt;This means you have to make sure the IDs are set to their values before calling -&amp;gt;persist().&lt;/p&gt;</comment>
                    <comment id="14943" author="beberlei" created="Fri, 10 Dec 2010 03:23:48 +0000"  >&lt;p&gt;This issue will be fixed when &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-117&quot; title=&quot;Allow @Id on @ManyToOne fields&quot;&gt;&lt;del&gt;DDC-117&lt;/del&gt;&lt;/a&gt; is merged into master. That will happen for the 2.1 release.&lt;/p&gt;</comment>
                    <comment id="15097" author="beberlei" created="Sun, 2 Jan 2011 06:05:33 +0000"  >&lt;p&gt;Implemented&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>