【发布时间】:2017-10-25 06:14:34
【问题描述】:
我希望用 executeUpdate 来做这件事,事情是在 GRAILS 中用 executeUpdate 连接一个字符串值
def transactions = Transaction.findAll()
for (tr in transactions) {
tr.comment = tr.comment + " new words...."
tr.save()
}
【问题讨论】:
我希望用 executeUpdate 来做这件事,事情是在 GRAILS 中用 executeUpdate 连接一个字符串值
def transactions = Transaction.findAll()
for (tr in transactions) {
tr.comment = tr.comment + " new words...."
tr.save()
}
【问题讨论】:
我没有尝试过,但是类似的东西
Transaction.executeUpdate("update Transaction t set t.comment=t.comment + :newComment", [newComment: 'new words...'])
或
Transaction.executeUpdate("update Transaction t set t.comment=concat(t.comment, :newComment), [newComment: 'new words...'])
【讨论】:
def transactions = Transaction.all //you can use findAll() also
for (Transaction tr : transactions) {
tr.comment = tr.comment + " new words...."
tr.save(flush:true)
}
希望对你有帮助
【讨论】: