<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Tue Jun 18 05:59:55 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-2244/DDC-2244.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-2244] One-To-Many Cascade saving not working properly</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2244</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;I have the following 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;
$&lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; InterviewReview();

$question = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; InterviewReviewQuestion();
$&lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt;-&amp;gt;addQuestion($question);

$em-&amp;gt;persist($&lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt;);
$em-&amp;gt;flush();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When i execute this code i have the following error:&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;
An exception occurred &lt;span class=&quot;code-keyword&quot;&gt;while&lt;/span&gt; executing &apos;INSERT INTO interview_review_question (question, tags, created_at, interview_review_id) VALUES (?, ?, ?, ?)&apos; with params {&lt;span class=&quot;code-quote&quot;&gt;&quot;1&quot;&lt;/span&gt;:&lt;span class=&quot;code-quote&quot;&gt;&quot;asdfg&quot;&lt;/span&gt;,&lt;span class=&quot;code-quote&quot;&gt;&quot;2&quot;&lt;/span&gt;:&lt;span class=&quot;code-quote&quot;&gt;&quot;asdfg&quot;&lt;/span&gt;,&lt;span class=&quot;code-quote&quot;&gt;&quot;3&quot;&lt;/span&gt;:&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;,&lt;span class=&quot;code-quote&quot;&gt;&quot;4&quot;&lt;/span&gt;:&lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;}:

Column &apos;interview_review_id&apos; cannot be &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here are my entities:&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;
/**
 * InterviewReview
 *
 * @ORM\Table(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;interview_review&quot;&lt;/span&gt;)
 * @ORM\Entity
 */
class InterviewReview
{
    /**
     * @&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; integer
     *
     * @ORM\Column(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;id&quot;&lt;/span&gt;, type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;

    /**
     * @&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; Doctrine\Common\Collections\ArrayCollection
     *
     * @ORM\OneToMany(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Absolvent\AbsolventBundle\Entity\InterviewReviewQuestion&quot;&lt;/span&gt;, cascade={&lt;span class=&quot;code-quote&quot;&gt;&quot;persist&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;remove&quot;&lt;/span&gt;}, mappedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;interview_review&quot;&lt;/span&gt;)
     * @ORM\JoinColumn(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;interview_review&quot;&lt;/span&gt;, referencedColumnName=&lt;span class=&quot;code-quote&quot;&gt;&quot;id&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $questions;

    /**
     * Add question
     *
     * @param \Absolvent\AbsolventBundle\Entity\InterviewReviewQuestion $question
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; InterviewReview
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function addQuestion(\Absolvent\AbsolventBundle\Entity\InterviewReviewQuestion $question)
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;questions[] = $question;

        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;;
    }

    /**
     * Remove question
     *
     * @param \Absolvent\AbsolventBundle\Entity\InterviewReviewQuestion $question
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function removeQuestion(\Absolvent\AbsolventBundle\Entity\InterviewReviewQuestion $question)
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;questions-&amp;gt;removeElement($question);
    }

    /**
     * Get questions
     *
     * @&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 getQuestions()
    {
        &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;questions;
    }
}


/**
 * InterviewReviewQuestion
 *
 * @ORM\Table(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;interview_review_question&quot;&lt;/span&gt;)
 * @ORM\Entity
 */
class InterviewReviewQuestion
{
    /**
     * @&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; integer
     *
     * @ORM\Column(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;id&quot;&lt;/span&gt;, type=&lt;span class=&quot;code-quote&quot;&gt;&quot;integer&quot;&lt;/span&gt;)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy=&lt;span class=&quot;code-quote&quot;&gt;&quot;AUTO&quot;&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $id;

    /**
     * @&lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; Absolvent\AbsolventBundle\Entity\InterviewReview
     *
     * @ORM\ManyToOne(targetEntity=&lt;span class=&quot;code-quote&quot;&gt;&quot;Absolvent\AbsolventBundle\Entity\InterviewReview&quot;&lt;/span&gt;, cascade={&lt;span class=&quot;code-quote&quot;&gt;&quot;persist&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;remove&quot;&lt;/span&gt;}, inversedBy=&lt;span class=&quot;code-quote&quot;&gt;&quot;questions&quot;&lt;/span&gt;)
     * @ORM\JoinColumn(name=&lt;span class=&quot;code-quote&quot;&gt;&quot;interview_review_id&quot;&lt;/span&gt;, referencedColumnName=&lt;span class=&quot;code-quote&quot;&gt;&quot;id&quot;&lt;/span&gt;, nullable=&lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;)
     */
    &lt;span class=&quot;code-keyword&quot;&gt;private&lt;/span&gt; $interview_review;

    /**
     * Get id
     *
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; integer
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getId()
    {
        &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;id;
    }

    /**
     * Set interview_review
     *
     * @param \Absolvent\AbsolventBundle\Entity\InterviewReview $interviewReview
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; InterviewReviewQuestion
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setInterviewReview(\Absolvent\AbsolventBundle\Entity\InterviewReview $interviewReview = &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;)
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;interview_review = $interviewReview;

        &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;;
    }

    /**
     * Get interview_review
     *
     * @&lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; \Absolvent\AbsolventBundle\Entity\InterviewReview
     */
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function getInterviewReview()
    {
        &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;interview_review;
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This problem is causing because the is no $question-&amp;gt;setInterviewReview() called anywhere.&lt;/p&gt;

&lt;p&gt;I know that i can call it inside addQuestion function, but is should work out of the box - isn&apos;t it?&lt;/p&gt;</description>
                <environment></environment>
            <key id="14388">DDC-2244</key>
            <summary>One-To-Many Cascade saving not working properly</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="6" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/closed.png">Closed</status>
                    <resolution id="6">Invalid</resolution>
                                <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="kl3ryk">Pawe&#322; &#321;askarzewski</reporter>
                        <labels>
                    </labels>
                <created>Tue, 15 Jan 2013 16:22:33 +0000</created>
                <updated>Tue, 15 Jan 2013 16:46:25 +0000</updated>
                    <resolved>Tue, 15 Jan 2013 16:44:24 +0000</resolved>
                                                            <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19321" author="ocramius" created="Tue, 15 Jan 2013 16:31:16 +0000"  >&lt;p&gt;Fixing code highlighting&lt;/p&gt;</comment>
                    <comment id="19322" author="kl3ryk" created="Tue, 15 Jan 2013 16:34:58 +0000"  >&lt;p&gt;Fixed&lt;/p&gt;</comment>
                    <comment id="19323" author="ocramius" created="Tue, 15 Jan 2013 16:35:21 +0000"  >&lt;p&gt;Works here with your code. What&apos;s the exact ORM version you&apos;re using?&lt;/p&gt;</comment>
                    <comment id="19324" author="ocramius" created="Tue, 15 Jan 2013 16:38:45 +0000"  >&lt;p&gt;Calling&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;$question-&amp;gt;setInterviewReview($&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;is up to you. Doctrine does not apply this kind of &quot;magic&quot;.&lt;br/&gt;
You are responsible for keeping your object graph consistent.&lt;/p&gt;</comment>
                    <comment id="19325" author="kl3ryk" created="Tue, 15 Jan 2013 16:40:10 +0000"  >&lt;p&gt;In composer (using symofny) i have:&lt;/p&gt;

&lt;p&gt;&quot;doctrine/orm&quot;: &quot;&amp;gt;=2.2,&amp;lt;2.4-dev&quot;&lt;/p&gt;

&lt;p&gt;and got the latest version.&lt;/p&gt;

&lt;p&gt;Lanuched composer update 2 hours ago&lt;/p&gt;</comment>
                    <comment id="19326" author="kl3ryk" created="Tue, 15 Jan 2013 16:41:18 +0000"  >&lt;p&gt;Ok but both objects are new and connected (using add function). I thought that cascade=&lt;/p&gt;
{&quot;persist&quot;}
&lt;p&gt; will do this magic &lt;img class=&quot;emoticon&quot; src=&quot;http://www.doctrine-project.org/jira/images/icons/emoticons/wink.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="19327" author="ocramius" created="Tue, 15 Jan 2013 16:44:17 +0000"  >&lt;p&gt;No, associating them is up to you. The ORM is only responsible for saving/loading data, not for manipulating your associations like that.&lt;/p&gt;</comment>
                    <comment id="19328" author="kl3ryk" created="Tue, 15 Jan 2013 16:44:17 +0000"  >&lt;p&gt;In the documentation there is some info about this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/working-with-associations.html#transitive-persistence-cascade-operations&quot; class=&quot;external-link&quot;&gt;http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/working-with-associations.html#transitive-persistence-cascade-operations&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Even if you persist a new User that contains our new Comment this code would fail if you removed the call to EntityManager#persist($myFirstComment). Doctrine 2 does not cascade the persist operation to all nested entities that are new as well.&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;....&amp;#93;&lt;/span&gt;&lt;br/&gt;
To have Doctrine handle both cases automatically we can change the User#commentsAuthored property to cascade both the &#8220;persist&#8221; and the &#8220;remove&#8221; operation.&lt;/p&gt;&lt;/blockquote&gt;</comment>
                    <comment id="19329" author="ocramius" created="Tue, 15 Jan 2013 16:45:09 +0000"  >&lt;p&gt;&lt;a href=&quot;http://www.doctrine-project.org/jira/secure/ViewProfile.jspa?name=kl3ryk&quot; class=&quot;user-hover&quot; rel=&quot;kl3ryk&quot;&gt;Pawe&#322; &#321;askarzewski&lt;/a&gt; see &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-2227&quot; title=&quot;Add details about developer being responsible of inverse side of an association&quot;&gt;DDC-2227&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="19330" author="kl3ryk" created="Tue, 15 Jan 2013 16:46:25 +0000"  >&lt;p&gt;Ok thanks for your help&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>