Reputation: 1269
I have a list def userList = User.findByStatus(true)
. I have to update the status of user to false. Is there a way to update the list without using iteration.
Upvotes: 0
Views: 88
Reputation: 24776
Of coruse there is! executeUpdate
is exactly what you are looking for. According to the documentation you can update matching records.
For example:
User.executeUpdate("update User u set u.status = false where u.status = true")
Upvotes: 2