<!-- 
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Thu Jun 20 01:52:49 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-2297/DDC-2297.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-2297] Add ConstraintException for parent row</title>
                <link>http://www.doctrine-project.org/jira/browse/DDC-2297</link>
                <project id="10032" key="DDC">Doctrine 2 - ORM</project>
                        <description>&lt;p&gt;Currently there is no constraint check for entities that depends another one.&lt;br/&gt;
I always check the dependencies using repository. Something 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;
$childRepository = $em-&amp;gt;getRepository(&apos;Child&apos;);
$parent = $em-&amp;gt;getReference(&apos;app:Parent&apos;, $id);
$children = $childRepository-&amp;gt;findBy(array(&apos;parent&apos; =&amp;gt; $parent));

&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($children) {
    &lt;span class=&quot;code-keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Exception(&apos;You can not delete &lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; record. There are records related&apos;);
}
        
$em-&amp;gt;remove($parent);
$em-&amp;gt;flush();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This exception could be thrown in $em-&amp;gt;flush(); or could look 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; 
try {
    $parentEntity = $em-&amp;gt;gerReference(&apos;ParentEntity&apos;, $id);
    $em-&amp;gt;remove($parentEntity);
    $em-&amp;gt;flush();
catch (SomeORMNamespace\ConstraintException $e) {
    echo $e-&amp;gt;getMessage(); //outs: You cannot remove this entity. There is another one related.
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;I think this functionality could be implemented through metadata on any sides of the relationship or on the @Entity mapping.&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;
@Entity(children={&apos;Child&apos;}) &lt;span class=&quot;code-comment&quot;&gt;//&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt; is not a good attr name =)
&lt;/span&gt;class Parent {}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I know that is more app business logic related, but is it possible to implement this feature in next releases?&lt;/p&gt;</description>
                <environment></environment>
            <key id="14483">DDC-2297</key>
            <summary>Add ConstraintException for parent row</summary>
                <type id="2" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/newfeature.png">New Feature</type>
                                <priority id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/trivial.png">Trivial</priority>
                    <status id="5" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/resolved.png">Resolved</status>
                    <resolution id="2">Won&apos;t Fix</resolution>
                                <assignee username="beberlei">Benjamin Eberlei</assignee>
                                <reporter username="yourwebmaker">Daniel Lima</reporter>
                        <labels>
                    </labels>
                <created>Fri, 15 Feb 2013 05:16:06 +0000</created>
                <updated>Fri, 15 Feb 2013 08:29:48 +0000</updated>
                    <resolved>Fri, 15 Feb 2013 08:29:47 +0000</resolved>
                                                            <component>ORM</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="19543" author="beberlei" created="Fri, 15 Feb 2013 08:29:47 +0000"  >&lt;p&gt;This is responsiblity of the the application developer.&lt;/p&gt;

&lt;p&gt;You can implement this generically using parts of the API shown below:&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;
$metadata = $entityManager-&amp;gt;getClassMetadata(&lt;span class=&quot;code-quote&quot;&gt;&quot;ClassName&quot;&lt;/span&gt;);

foreach ($metadata-&amp;gt;associationMappings as $assoc) {
   &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($assoc[&apos;type&apos;] &amp;amp; ClassMetadata::TO_ONE) {
      
   }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>