[mythtv-users] Problem with self referenced associations

Andréas Kühne andreas at kuhne.se
Sat Nov 2 20:44:22 UTC 2013


Hi,

I have a domain that has several one to many relationship with itself. They
are declared by the following:

class Contact {
static hasMany = [ bosses: Contact, coworkers: Contact ]
static mapping = [ bosses: 'bosses', coworkers: 'coworkers' ]

def beforeDelete() {
Contact.withNewSession { session ->
for (Contact boss: this.bosses)
this.removeBoss(boss)
for (Contact coworker: this.coworkers)
this.removeCoworker(coworker)
}
return true
}
}

(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.

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?

Regards,

Andréas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20131102/a9915bbb/attachment.html>


More information about the mythtv-users mailing list