例如,我需要在表中检索多个寄存器并编辑一个字段,但是用循环保存所需时间太长,是否存在一个更好的保存方法? 该怎么办呢....如何在Grails中同时保存一个集合
class Table
static mapping = {
table "TABLEEX"
id generator:'sequence', params:[sequence:'TABLEEX_SEQ']
}
// identificacion
String data1
String data2
}
和搜索数据:
def stuff = Table.createCriteria().list{
eq("data1","1")
}
与编辑和保存
stuff.each {
it.data2 = "aaa"
it.save()
}
使用'where'查询将允许你这样做未做一堆往返于数据库。请参阅下面的答案。 – 2014-11-24 16:10:50