|
4 | 4 | */ |
5 | 5 | package org.hibernate.sql.ast.spi; |
6 | 6 |
|
| 7 | +import org.hibernate.Incubating; |
7 | 8 | import org.hibernate.sql.ast.tree.from.TableGroup; |
8 | 9 | import org.hibernate.sql.ast.tree.from.TableGroupJoin; |
9 | 10 |
|
10 | 11 | import java.util.Collection; |
11 | 12 |
|
12 | | -/** |
13 | | - * Strategy for dealing with locking via a SQL {@code FOR UPDATE (OF)} |
14 | | - * clause. |
15 | | - * <p/> |
16 | | - * Some dialects do not use a {@code FOR UPDATE (OF)} to apply |
17 | | - * locks - e.g., they apply locks in the {@code FROM} clause. Such |
18 | | - * dialects would return a no-op version of this contract. |
19 | | - * <p/> |
20 | | - * Some dialects support an additional {@code FOR SHARE (OF)} clause |
21 | | - * as well to acquire non-exclusive locks. That is also handled here, |
22 | | - * varied by the requested {@linkplain org.hibernate.LockMode LockMode}. |
23 | | - * <p/> |
24 | | - * Operates in 2 "phases"-<ol> |
25 | | - * <li> |
26 | | - * collect tables which are to be locked (based on {@linkplain org.hibernate.Locking.Scope}, |
27 | | - * and other things) |
28 | | - * </li> |
29 | | - * <li> |
30 | | - * render the appropriate locking fragment |
31 | | - * </li> |
32 | | - * </ol> |
33 | | - * |
34 | | - * @see org.hibernate.dialect.Dialect#getLockingClauseStrategy |
35 | | - * |
36 | | - * @author Steve Ebersole |
37 | | - */ |
| 13 | +/// Strategy for dealing with locking via a SQL `FOR UPDATE (OF)` |
| 14 | +/// clause. |
| 15 | +/// |
| 16 | +/// Some dialects do not use a `FOR UPDATE (OF)` to apply |
| 17 | +/// locks - e.g., they apply locks in the `FROM` clause. Such |
| 18 | +/// dialects would return a no-op version of this contract. |
| 19 | +/// |
| 20 | +/// Some dialects support an additional `FOR SHARE (OF)` clause |
| 21 | +/// as well to acquire non-exclusive locks. That is also handled here, |
| 22 | +/// varied by the requested {@linkplain org.hibernate.LockMode LockMode}. |
| 23 | +/// |
| 24 | +/// Operates in 2 "phases"- |
| 25 | +/// * collect tables which are to be locked (based on {@linkplain org.hibernate.Locking.Scope}, and other things) |
| 26 | +/// * render the appropriate locking fragment |
| 27 | +/// |
| 28 | +/// @implSpec Note that this is also used to determine and track which |
| 29 | +/// tables to lock even for cases (T-SQL e.g.) where a "locking clause" |
| 30 | +/// per-se won't be used. In such cases, only the first phase (along |
| 31 | +/// with [#shouldLockRoot] and [#shouldLockJoin]) have any impact. |
| 32 | +/// |
| 33 | +/// @see org.hibernate.dialect.Dialect#getLockingClauseStrategy |
| 34 | +/// |
| 35 | +/// @author Steve Ebersole |
| 36 | +@Incubating |
38 | 37 | public interface LockingClauseStrategy { |
| 38 | + /// Should the specified `root` be locked |
39 | 39 | boolean shouldLockRoot(TableGroup root); |
| 40 | + /// Should the specified `joinedGroup` be locked |
40 | 41 | boolean shouldLockJoin(TableGroup joinedGroup); |
41 | 42 |
|
| 43 | + /// Register the given `root` |
42 | 44 | void registerRoot(TableGroup root); |
43 | | - void registerJoin(TableGroupJoin join); |
| 45 | + /// Register the given `joinedGroup` |
| 46 | + void registerJoin(TableGroupJoin joinedGroup); |
44 | 47 |
|
| 48 | + /// Are any outer joins encountered during registration |
| 49 | + /// of [roots][#registerRoot] and [joins][#registerJoin] |
45 | 50 | boolean containsOuterJoins(); |
46 | 51 |
|
| 52 | + /// For cases where a locking clause is to be used, |
| 53 | + /// render that locking clause. |
47 | 54 | void render(SqlAppender sqlAppender); |
48 | 55 |
|
| 56 | + /// All roots to be locked. |
49 | 57 | Collection<TableGroup> getRootsToLock(); |
| 58 | + /// All joins to be locked. |
50 | 59 | Collection<TableGroupJoin> getJoinsToLock(); |
51 | 60 | } |
0 commit comments