【发布时间】:2011-02-04 13:05:58
【问题描述】:
我正在研究 Grails。 在某些时候,我必须根据它们的 id 从数据库中获取大量对象。 如果我按 id 做这个,性能很差。
ids.each{
Myclass.findById( id )
...
}
鉴于对于存储批次有有用的 withTransaction 闭包,是否可以执行类似的操作来获取对象,而不是存储它们?
另一个想法可能是长 HQL 查询,例如:
"select * from Myclass where (id = 1) OR ( id = 2) ... OR ( id = n )"
这是一个好的解决方案吗?
谢谢!
【问题讨论】:
标签: grails transactions batch-file grails-orm