6
6
7
7
import jakarta .persistence .PessimisticLockScope ;
8
8
import jakarta .persistence .Timeout ;
9
- import org .hibernate .query .Query ;
10
9
11
10
import java .io .Serializable ;
12
11
import java .util .HashMap ;
28
27
* {@link Session#refresh(Object, LockOptions)}, the relevant options
29
28
* are:
30
29
* <ul>
31
- * <li>the {@linkplain #getLockMode() lock mode},
32
- * <li>the {@linkplain #getTimeOut() pessimistic lock timeout}, and
33
- * <li>the {@linkplain #getLockScope() lock scope}, that is, whether
30
+ * <li>the {@linkplain #getLockMode lock mode},
31
+ * <li>the {@linkplain #getTimeOut pessimistic lock timeout}, and
32
+ * <li>the {@linkplain #getLockScope lock scope}, that is, whether
34
33
* the lock extends to rows of owned collections.
35
34
* </ul>
36
35
* <p>
48
47
* default behavior of the SQL dialect} by passing a non-null argument
49
48
* to {@link #setFollowOnLocking(Boolean)}.
50
49
*
50
+ * @deprecated
51
+ * Since JPA 3.2 and Hibernate 7, a {@link LockMode}, {@link Timeout},
52
+ * or {@link PessimisticLockScope} may be passed directly as an option
53
+ * to {@code find()}, {@code refresh()}, or {@code lock()}. Therefore,
54
+ * this class is obsolete as an API and will be moved to an SPI package.
55
+ * <p>
56
+ * For HQL/JPQL queries, locking should be controlled via operations of
57
+ * the {@link org.hibernate.query.SelectionQuery} interface:
58
+ * <ul>
59
+ * <li>A timeout may be set via
60
+ * {@link org.hibernate.query.CommonQueryContract#setTimeout(Timeout)}
61
+ * <li>The {@code PessimisticLockScope} may be set using
62
+ * {@link org.hibernate.query.SelectionQuery#setLockScope(PessimisticLockScope)}
63
+ * <li>Alias-specific lock modes may be specified using
64
+ * {@link org.hibernate.query.SelectionQuery#setLockMode(String, LockMode)}
65
+ * <li>Use of follow-on locking may be enabled via
66
+ * {@link org.hibernate.query.SelectionQuery#setFollowOnLocking(boolean)}
67
+ * </ul>
68
+ * The interface {@link Timeouts} provides several operations to simplify
69
+ * migration.
70
+ *
71
+ * @see LockMode
72
+ * @see Timeouts
73
+ *
51
74
* @author Scott Marlow
52
75
*/
76
+ @ Deprecated (since = "7.0" , forRemoval = true ) // moving to an SPI package
53
77
public class LockOptions implements Serializable {
54
78
/**
55
79
* Represents {@link LockMode#NONE}, to which timeout and scope are
@@ -191,7 +215,7 @@ public LockOptions(LockMode lockMode, int timeout) {
191
215
192
216
/**
193
217
* Construct an instance with the given {@linkplain LockMode mode},
194
- * timeout, and {@link PessimisticLockScope scope}.
218
+ * timeout, and {@linkplain PessimisticLockScope scope}.
195
219
*
196
220
* @param lockMode The initial lock mode
197
221
* @param timeout The initial timeout
@@ -206,7 +230,7 @@ public LockOptions(LockMode lockMode, Timeout timeout, PessimisticLockScope scop
206
230
207
231
/**
208
232
* Construct an instance with the given {@linkplain LockMode mode},
209
- * timeout, and {@link PessimisticLockScope scope}.
233
+ * timeout, and {@linkplain PessimisticLockScope scope}.
210
234
*
211
235
* @param lockMode The initial lock mode
212
236
* @param timeout The initial timeout, in milliseconds
@@ -228,6 +252,7 @@ private LockOptions(boolean immutable, LockMode lockMode) {
228
252
timeout = Timeouts .WAIT_FOREVER ;
229
253
pessimisticLockScope = NORMAL ;
230
254
}
255
+
231
256
/**
232
257
* Determine of the lock options are empty.
233
258
*
@@ -273,7 +298,7 @@ public LockOptions setLockMode(LockMode lockMode) {
273
298
* @param lockMode the lock mode to apply to the given alias
274
299
* @return {@code this} for method chaining
275
300
*
276
- * @see Query#setLockMode(String, LockMode)
301
+ * @see org.hibernate.query. Query#setLockMode(String, LockMode)
277
302
*/
278
303
public LockOptions setAliasSpecificLockMode (String alias , LockMode lockMode ) {
279
304
if ( immutable ) {
@@ -307,8 +332,8 @@ public LockMode getAliasSpecificLockMode(String alias) {
307
332
308
333
/**
309
334
* Determine the {@link LockMode} to apply to the given alias. If no
310
- * mode was {@linkplain #setAliasSpecificLockMode(String, LockMode)}
311
- * explicitly set}, the {@linkplain #getLockMode()} overall mode} is
335
+ * mode was {@linkplain #setAliasSpecificLockMode(String, LockMode)
336
+ * explicitly set}, the {@linkplain #getLockMode() overall mode} is
312
337
* returned. If the overall lock mode is also {@code null},
313
338
* {@link LockMode#NONE} is returned.
314
339
* <p>
@@ -432,7 +457,8 @@ public int getTimeOut() {
432
457
}
433
458
434
459
/**
435
- * Set the {@linkplain #getTimeout() timeout}, in milliseconds, associated with {@code this} options.
460
+ * Set the {@linkplain #getTimeout() timeout}, in milliseconds, associated
461
+ * with {@code this} options.
436
462
* <p/>
437
463
* {@link #NO_WAIT}, {@link #WAIT_FOREVER}, or {@link #SKIP_LOCKED}
438
464
* represent 3 "magic" values.
0 commit comments