To finish this question, I wanted to report a solution to my "problem." I use namedQuery in the parent object (Customer or Producer) as follows:
Class Customer { static hasMany = [channels: Channel] static namedQueries = { findByChannel { channelId -> channels { eq 'id', channelId } } } }
Then I find Customer as follows:
def customers = Customer.findByChannel(channel.id).list()
Thus, the Channel is freed from the burden of knowing something about who is referencing it, and I do not need to make any artificial link tables.
I still think it must be some kind of error, that I cannot use one of the dynamic searchers:
Customer.findByChannels([channel] as Set)
Perhaps dynamic crawlers do not take into account the one-to-many relationship and work only for simple attributes ??? (I am using Grails 1.3.1)
Thank you for your responses!
Christian Sonn Jensen
source share