I'm working on Grails. At some point I have to fetch large sets of objects from the db, based on their ids. If I do this id by id, the performance is very bad.
ids.each{
Myclass.findById( id )
...
}
Given that for storing batches there's the useful withTransaction closure, is it possible to do something like that to fetch objects, instead of storing them?
Another idea could be a long HQL query like:
"select * from Myclass where (id = 1) OR ( id = 2) ... OR ( id = n )"
Is this an ok solution?
Thanks!