Bhuwan Gautam
Bhuwan Gautam

Reputation: 1269

Update list's entity value without using loop

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

Answers (1)

Joshua Moore
Joshua Moore

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

Related Questions