Interface LockingClauseStrategy


@Incubating public interface LockingClauseStrategy

Strategy for dealing with locking via a SQL FOR UPDATE (OF) clause.

Some dialects do not use a FOR UPDATE (OF) to apply locks - e.g., they apply locks in the FROM clause. Such dialects would return a no-op version of this contract.

Some dialects support an additional FOR SHARE (OF) clause as well to acquire non-exclusive locks. That is also handled here, varied by the requested LockMode.

Operates in 2 "phases"-

  • collect tables which are to be locked (based on Locking.Scope, and other things)
  • render the appropriate locking fragment
See Also:
Implementation Specification:

Note that this is also used to determine and track which tables to lock even for cases (T-SQL e.g.) where a "locking clause" per-se won't be used. In such cases, only the first phase (along with

invalid reference
#shouldLockRoot
and
invalid reference
#shouldLockJoin
) have any impact.
  • Method Details

    • registerRoot

      boolean registerRoot(TableGroup root)
      Register the given root
      Returns:
      Whether the root ought to be locked
    • registerJoin

      boolean registerJoin(TableGroupJoin join)
      Register the given join
      Returns:
      Whether the join ought to be locked
    • containsOuterJoins

      boolean containsOuterJoins()
      Are any outer joins encountered during registration of roots and joins
    • render

      void render(SqlAppender sqlAppender)
      For cases where a locking clause is to be used, render that locking clause.
    • getPathsToLock

      Collection<NavigablePath> getPathsToLock()