<!--
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Sat May 18 15:39:44 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/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+DDC+AND+fixVersion+%3D+%222.1.8%22+ORDER+BY+updated+DESC%2C+priority+DESC%2C+created+ASC&tempMax=1000&field=key&field=summary
-->
<!-- If you wish to do custom client-side styling of RSS, uncomment this:
<?xml-stylesheet href="http://www.doctrine-project.org/jira/styles/jiraxml2html.xsl" type="text/xsl"?>
-->
<rss version="0.92">
    <channel>
        <title>Doctrine Project</title>
        <link>http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+DDC+AND+fixVersion+%3D+%222.1.8%22+ORDER+BY+updated+DESC%2C+priority+DESC%2C+created+ASC</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="1" total="1"/>
                <build-info>
            <version>5.2.7</version>
            <build-number>850</build-number>
            <build-date>21-02-2013</build-date>
        </build-info>
<item>
            <title>[DDC-1925] Bug in UnitOfWork and ManyToMany relations</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-1925</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Lets say, I have entity Forum with ManyToMany relations with User.&lt;br/&gt;
I need to validate user changes and I use code like&lt;/p&gt;

&lt;p&gt;$uow = $this-&amp;gt;getDoctrine()&lt;del&gt;&amp;gt;getEntityManager()&lt;/del&gt;&amp;gt;getUnitOfWork();&lt;br/&gt;
$uow-&amp;gt;computeChangeSets();&lt;br/&gt;
$changeSet = $uow-&amp;gt;getEntityChangeSet($forum);&lt;br/&gt;
if (.... bla-bla-bla....) &lt;/p&gt;
{
    $em = $this-&amp;gt;getDoctrine()-&amp;gt;getEntityManager();
    $em-&amp;gt;persist($forum);
    $em-&amp;gt;flush();
}

&lt;p&gt;Unfortunately, whenever I try to change manyToMany relations - I got error&lt;br/&gt;
 SQLSTATE&lt;span class=&quot;error&quot;&gt;&amp;#91;23000&amp;#93;&lt;/span&gt;: Integrity constraint violation: 1062 Duplicate entry &apos;4-4&apos; for key &apos;PRIMARY&apos;&lt;/p&gt;

&lt;p&gt;If I comment uow code - everything works just great.&lt;/p&gt;

&lt;p&gt;It looks like bug in UnitOfWork implementation.&lt;/p&gt;

&lt;p&gt;Let me know if you need more details from me.&lt;/p&gt;</description>
                <environment>symfony2</environment>
            <key id="13852">DDC-1925</key>
            <summary>Bug in UnitOfWork and ManyToMany relations</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="1">Fixed</resolution>
                    <security id="10000">All</security>
                        <assignee username="ocramius">Marco Pivetta</assignee>
                                <reporter username="zhil">Andrew</reporter>
                        <labels>
                    </labels>
                <created>Sat, 14 Jul 2012 04:44:52 +0000</created>
                <updated>Sun, 29 Jul 2012 10:12:07 +0000</updated>
                    <resolved>Sun, 29 Jul 2012 10:12:07 +0000</resolved>
                            <version>2.1</version>
                                <fixVersion>2.1.8</fixVersion>
                <fixVersion>2.3</fixVersion>
                                <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>3</watches>
                        <comments>
                    <comment id="18309" author="ocramius" created="Mon, 16 Jul 2012 01:04:01 +0000"  >&lt;p&gt;What is the part you commented out? Also, in what context is your code executed?&lt;/p&gt;</comment>
                    <comment id="18311" author="zhil" created="Mon, 16 Jul 2012 09:15:49 +0000"  >&lt;p&gt;I got error when $em-&amp;gt;persist($forum); $em-&amp;gt;flush();  executed.&lt;/p&gt;

&lt;p&gt;I can create github repository with code, which reproduce this error, if you want.&lt;/p&gt;</comment>
                    <comment id="18312" author="ocramius" created="Mon, 16 Jul 2012 09:19:26 +0000"  >&lt;p&gt;Please do&lt;/p&gt;</comment>
                    <comment id="18313" author="zhil" created="Mon, 16 Jul 2012 09:27:01 +0000"  >&lt;p&gt;that would be simple symfony2 application - will it work for you?&lt;/p&gt;</comment>
                    <comment id="18314" author="ocramius" created="Mon, 16 Jul 2012 09:28:57 +0000"  >&lt;p&gt;As long as the code is related to doctrine. Otherwise this issue is quite incomplete &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="18317" author="zhil" created="Mon, 16 Jul 2012 17:30:57 +0000"  >&lt;p&gt;Done, please check &lt;a href=&quot;https://github.com/zhil/testDoctrine&quot; class=&quot;external-link&quot;&gt;https://github.com/zhil/testDoctrine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In few words, when I add code like &lt;br/&gt;
$uow = $this-&amp;gt;getDoctrine()&lt;del&gt;&amp;gt;getEntityManager()&lt;/del&gt;&amp;gt;getUnitOfWork();&lt;br/&gt;
$uow-&amp;gt;computeChangeSets();&lt;br/&gt;
$changeSet = $uow-&amp;gt;getEntityChangeSet($product);&lt;/p&gt;

&lt;p&gt;before $em-&amp;gt;persist(); $em-&amp;gt;flush();&lt;/p&gt;

&lt;p&gt;I got fake MYSQL error &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;

&lt;p&gt;Thank in advance for your help &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="18342" author="zhil" created="Thu, 19 Jul 2012 18:36:59 +0000"  >&lt;p&gt;Just wonder - is it bug in doctrine2 or its problems somewhere else? (symfony2/my code/ etc.)&lt;/p&gt;

&lt;p&gt;This is part of the live project - I need to fix it &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="18343" author="ocramius" created="Thu, 19 Jul 2012 18:45:44 +0000"  >&lt;p&gt;I think it is related with the fact that you&apos;re using the `UnitOfWork` manually. You can probably try to fix the problem by moving your code to an event subscriber until this is fixed.&lt;/p&gt;</comment>
                    <comment id="18344" author="zhil" created="Thu, 19 Jul 2012 19:15:09 +0000"  >&lt;p&gt;Well, I used UnitOfWork, because I need to know what was changed during object validation (for example, property status can be changed only in predefined cases etc.).&lt;/p&gt;

&lt;p&gt;Ok, thanks for the suggestion - I will implement some temporary solution for this problem &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="18345" author="ocramius" created="Thu, 19 Jul 2012 19:17:07 +0000"  >&lt;p&gt;I think I spotted where this happens, but I don&apos;t have a clear overview on the situation. Will try to work on this...&lt;/p&gt;</comment>
                    <comment id="18346" author="zhil" created="Thu, 19 Jul 2012 19:36:33 +0000"  >&lt;p&gt;Thanks for the checking this issue.&lt;br/&gt;
I have already patched my application with ugly patch. Just in case solution will take some time and somebody else will need similar patch. I patched entity like&lt;/p&gt;

&lt;p&gt;entity {&lt;br/&gt;
 public $previousStatusBugfix = -1;&lt;br/&gt;
 public function setStatus($status)&lt;/p&gt;
    {
        // check http://www.doctrine-project.org/jira/browse/DDC-1925?focusedCommentId=18344#comment-18344
        // Ticket #651
        $this-&amp;gt;previousStatusBugfix = $this-&amp;gt;status;
        $this-&amp;gt;status = $status;
    }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;and validator&lt;/p&gt;

&lt;p&gt;if(($object-&amp;gt;previousStatusBugfix != &lt;del&gt;1) &amp;amp;&amp;amp; ($object&lt;/del&gt;&amp;gt;previousStatusBugfix != $object-&amp;gt;getStatus())) &lt;/p&gt;
{
                $changeSet = array(&quot;status&quot;=&amp;gt;array(0=&amp;gt;$object-&amp;gt;previousStatusBugfix, 1=&amp;gt;$object-&amp;gt;getStatus()));
            }

&lt;p&gt;&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="18347" author="ocramius" created="Thu, 19 Jul 2012 21:43:51 +0000"  >&lt;p&gt;I just wrote a couple of tests (attaching them to the issue shortly) and found out that on `&amp;gt;=2.2.x` your code runs perfectly.&lt;br/&gt;
The problem is on the `2.1.x` branch, and the commit that fixed the issue is &lt;a href=&quot;https://github.com/doctrine/doctrine2/commit/4474d30&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/commit/4474d30&lt;/a&gt; for &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-1210&quot; title=&quot;if I call computeAssociationChanges twice it will add this collection twice&quot;&gt;&lt;del&gt;DDC-1210&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now looking if it can be merged into `2.1.x` since it doesn&apos;t seem to cause any BC break.&lt;/p&gt;</comment>
                    <comment id="18348" author="beberlei" created="Thu, 19 Jul 2012 22:03:20 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-402&amp;#93;&lt;/span&gt; was opened&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/402&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/402&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="18349" author="beberlei" created="Thu, 19 Jul 2012 22:07:13 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-403&amp;#93;&lt;/span&gt; was opened&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/403&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/403&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="18350" author="ocramius" created="Thu, 19 Jul 2012 22:16:07 +0000"  >&lt;p&gt;Duplicate of &lt;a href=&quot;http://www.doctrine-project.org/jira/browse/DDC-1210&quot; title=&quot;if I call computeAssociationChanges twice it will add this collection twice&quot;&gt;&lt;del&gt;DDC-1210&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="18366" author="beberlei" created="Mon, 23 Jul 2012 05:02:17 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-403&amp;#93;&lt;/span&gt; was closed&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/403&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/403&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="18410" author="beberlei" created="Sun, 29 Jul 2012 10:09:18 +0000"  >&lt;p&gt;A related Github Pull-Request &lt;span class=&quot;error&quot;&gt;&amp;#91;GH-402&amp;#93;&lt;/span&gt; was closed&lt;br/&gt;
&lt;a href=&quot;https://github.com/doctrine/doctrine2/pull/402&quot; class=&quot;external-link&quot;&gt;https://github.com/doctrine/doctrine2/pull/402&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>