liveBook · Manning

FOR UPDATE clause

A FOR UPDATE clause requests locks on rows selected by a query, restricting concurrent modifications until the transaction ends.

How 2 Manning books explain it

Just Use Postgres!

A FOR UPDATE clause locks selected rows so that concurrent transactions cannot independently modify or process them until the lock-holding transaction ends.

How it is used
Coordinates concurrent message consumers by reserving selected queue rows during dequeue processing.
How deep it goes
Explains row-level locks, transaction boundaries, SKIP LOCKED behavior, and a complete dequeue implementation.
Examples
Uses a PostgreSQL queue table, a dequeue function, concurrent consumers, and explicit transaction blocks.
What you can do after
Operate concurrent queue consumers that reserve messages without blocking on rows already being processed.

Read how Just Use Postgres! explains FOR UPDATE clause →

Java Persistence with Spring Data and Hibernate epub

FOR UPDATE is an SQL locking clause that requests exclusive row locks for rows selected by a query.

How it is used
Applies pessimistic locking when a transaction must safely read and update concurrently accessed rows.
How deep it goes
Explains provider translation, database dialect differences, lock duration, timeout behavior, and optimistic-conflict timing.
Examples
Uses H2, PostgreSQL, and MySQL translations plus EntityManager queries with pessimistic read and write modes.
What you can do after
Operate/configure pessimistic locks through JPA lock modes, timeout hints, transactions, and database dialect settings.

Read how Java Persistence with Spring Data and Hibernate epub explains FOR UPDATE clause →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.