views:

286

answers:

1

Hi,
as I am new to Grails and dynamic languages, I do have some 'hopefully simple' question.

I installed the taggable plugin which works fine. There is an array coming in with tags. I collect for every tag the set of data with findAllByTag. After that I randomise it and pick one entry. Works great. Now I decided not to take all objects from the DB. I only need all with a certain creteria(DB column customerID). This would look like this:
def customerSet = Customer.findAllBycustomerID(params.customerID)

I got both querys working, but can not combine as I want. I tried something like
def hits = customerSet.findAllByTag(tag)
But then I get a groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.findAllByTag() is applicable for argument types: (java.lang.String) values: [mac]
I guess I can not do a findAllByTag on a list like that.

Or do I have to do it somehow like this: def customerSet = Customer.findAllBycustomerID(params.customerID.findAllByTag(tag)) ???

thanks, klaas

+1  A: 

I'm not sure if this works with taggable but you can use a dynamic finder with two properties e.g. .findAllByCustomerIdAndTag(customerId,tag)

If that doesn't work, you can use a criteria e.g.

Customer.createCriteria().list{
    eq('customerId',someCustomerId)
    tags{
        eq('name',someTag')
    }
}
leebutts