<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: 'bosses', coworkers: 'coworkers' ]</div><div><br></div><div>def beforeDelete() {<br></div><div><div><span class="" style="white-space:pre">        </span>Contact.withNewSession { session -><br>
</div><div><span class="" style="white-space:pre">                </span>for (Contact boss: this.bosses)</div><div><span class="" style="white-space:pre">                        </span>this.removeBoss(boss)</div><div><span class="" style="white-space:pre">                </span>for (Contact coworker: this.coworkers)</div>
<div><span class="" style="white-space:pre">                        </span>this.removeCoworker(coworker)</div><div><span class="" style="white-space:pre">        </span>}<br></div><div><span class="" style="white-space:pre">        </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'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">Regards,<br><br>Andréas<br></div></div>
</div></div>