<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 2, 2013 at 4:44 PM, Andréas Kühne <span dir="ltr">&lt;<a href="mailto:andreas@kuhne.se" target="_blank">andreas@kuhne.se</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have a domain that has several one to many relationship with itself. They are declared by the following:</div>
<div><br></div><div>class Contact {</div><div>static hasMany = [ bosses: Contact, coworkers: Contact ]</div>
<div>static mapping = [ bosses: &#39;bosses&#39;, coworkers: &#39;coworkers&#39; ]</div><div><br></div><div>def beforeDelete() {<br></div><div><div><span style="white-space:pre-wrap">        </span>Contact.withNewSession { session -&gt;<br>

</div><div><span style="white-space:pre-wrap">                </span>for (Contact boss: this.bosses)</div><div><span style="white-space:pre-wrap">                        </span>this.removeBoss(boss)</div><div><span style="white-space:pre-wrap">                </span>for (Contact coworker: this.coworkers)</div>

<div><span style="white-space:pre-wrap">                        </span>this.removeCoworker(coworker)</div><div><span style="white-space:pre-wrap">        </span>}<br></div><div><span style="white-space:pre-wrap">        </span>return true</div>
<div>}</div></div><div>}</div><div><br></div><div>(this is just a snippet of the code, the code that I am having problems with). The problem I am having is when the beforeDelete event is run I get a NullPointerException in the line where I try to iterate over the bosses. </div>

<div><br></div><div>I can&#39;t seem to get this to work and was wondering if anyone has any ideas or could point me in the right direction?</div><div><br clear="all"><div><div dir="ltr"><br></div></div></div></div></blockquote>
<div><br></div><div>I&#39;m going to take a wild guess and say you sent this to the wrong list. Someone may be able to help you though... :)</div><div><br></div><div>Tom </div></div></div></div>