Interface LockingClauseStrategy
@Incubating(since="7.1",
group="dialect-locking")
@SPI({USE,IMPLEMENT,SUPPLY})
public interface LockingClauseStrategy
Per-translation strategy for collecting lock targets and rendering statement-level pessimistic locking.
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.
The translator uses each instance in two ordered phases:
- register roots and joins while traversing the from clause; and
- render the locking fragment after statement rendering reaches the database-specific clause position.
Implementations may retain state collected during the first phase, so an
instance belongs to one translation and must not be cached or reused. Prefer
composing LockingClauseRenderer through the standard strategy unless
target collection itself differs.
- Since:
- 8.0
- 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
shouldLockRoot()andshouldLockJoin()) have any impact.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether registration encountered any join.booleanWhether registration encountered an outer join.The navigable paths selected for locking during registration.booleanregisterJoin(TableGroupJoin join) Register the given table-group join during from-clause traversal.booleanregisterRoot(TableGroup root) Register the given root table group during from-clause traversal.voidrender(SqlAppender sqlAppender) Render the locking fragment at the position selected by the translator.
-
Method Details
-
registerRoot
Register the given root table group during from-clause traversal.- Returns:
- whether the translator should render this root as locked
-
registerJoin
Register the given table-group join during from-clause traversal.- Returns:
- whether the translator should render this join as locked
-
containsOuterJoins
boolean containsOuterJoins()Whether registration encountered an outer join. -
containsJoins
boolean containsJoins()Whether registration encountered any join. -
render
Render the locking fragment at the position selected by the translator. A no-clause strategy performs no output. -
getPathsToLock
Collection<NavigablePath> getPathsToLock()The navigable paths selected for locking during registration.
-