grails中的executeUpdate

时间:2017-05-24 18:38:14

标签: grails hql

我希望用executeUpdate执行此操作,事情是使用GRAILS中的executeUpdate连接一个字符串值

def transactions = Transaction.findAll()

for (tr in transactions) {
   tr.comment = tr.comment + " new words...."
   tr.save()
}

2 个答案:

答案 0 :(得分:1)

我没有尝试过这样的事情

Transaction.executeUpdate("update Transaction t set t.comment=t.comment + :newComment", [newComment: 'new words...'])

OR

Transaction.executeUpdate("update Transaction t set t.comment=concat(t.comment, :newComment), [newComment: 'new words...'])

答案 1 :(得分:0)

{{1}}

希望它能帮到你