0

As documented we could use obtain pessimistic lock like this:

def airport = Airport.get(10, [lock:true)
airport.lock() // lock for update
airport.name = "Heathrow"
airport.save()

I tried to de the same think with getAll but it doesn't work

def airport = Airport.getAll(idsList, [lock:true])

Error:

getAll() is applicable for argument types: (java.util.ArrayList, java.util.LinkedHashMap)...

Is there another way to obtain a pessimistic lock for a list?

Thanks

Jils
  • 783
  • 5
  • 12
  • 32
  • 1
    Assuming `airports` is a collection of your domain instances you could use the spread dot operator like this: `airports*.lock()` Otherwise, no. – Joshua Moore Oct 30 '14 at 09:56
  • If I use `findAllByIdInList`, can I avoid the use of pessimistic lock? – Jils Oct 30 '14 at 12:00
  • See my previous answer regarding how to control pesimistic locks: http://stackoverflow.com/questions/25808440/pessimistic-locking-in-gorm-where-query – Joshua Moore Oct 30 '14 at 12:02
  • Unrelated - you're using a weird locking approach - instead of `[lock:true]` or `lock()` after retrieving (or both, why 2?) just use the static lock method so there's no gap between retrieval and lock: `def airport = Airport.lock(10)` – Burt Beckwith Oct 30 '14 at 19:14

0 Answers0