[mythtv-users] Problem with self referenced associations

Tom Lichti tom at redpepperracing.com
Sat Nov 2 22:02:31 UTC 2013


On Sat, Nov 2, 2013 at 4:44 PM, Andréas Kühne <andreas at kuhne.se> wrote:

> 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?
>
>
>
I'm going to take a wild guess and say you sent this to the wrong list.
Someone may be able to help you though... :)

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20131102/5f7c8830/attachment.html>


More information about the mythtv-users mailing list