[mythtv-users] Problem with self referenced associations

Andréas Kühne andreas at kuhne.se
Sun Nov 3 13:21:06 UTC 2013


2013/11/2 Tom Lichti <tom at redpepperracing.com>

> 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
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
>
>
Tom,

Thats not such a wild guess. Must have been tired yesterday! Thanks all :-)

Regards,

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


More information about the mythtv-users mailing list