I have a class like this:

class Foo {
    String bar
}

I am trying to get the IDs of all the Foo objects whose bar String is in the list bars. I have tried it several ways, always receiving the same error:

java.lang.String cannot be cast to java.util.Collection

Some of the things I have tried:

def ids = Foo.findAllByBarInList( bars )*.id
def ids = Foo.findAllByBarInList( bars ).collect{ it.id }
def ids = Foo.findAllByBarInList( bars ).collect{ it -> it?.id }

UPDATE:

I was making bars with split so it was an array, not a list. It threw me off because Foo.findAllByBarInList( bars ) returned my Foo objects just fine, only when I tried to collect the ids did it fail. I now make bars with tokenize instead and all is well.

Edit
Report