(Quick Reference)
lock
目的
Purpose
The
lock
method obtains a pessimistic lock using an SQL
select … for update
.
使用例
Examples
def book = Book.get(1)
book.lock()
詳細
Description
The
lock
method obtains a pessimistic lock on an instance, locking the row in the database with
select … for update
. The
lock
method is equivalent to using Hibernate's
LockMode.UPGRADE in combination with the
lock method.
The lock is automatically released when the transaction commits. In Grails this is typically after an action has finished executing.
Refer to the section on
Optimistic and Pessimistic locking in the user guide for info.