6
6
*/
7
7
package org .hibernate ;
8
8
9
- import java .io .Serializable ;
10
9
import java .util .Iterator ;
11
10
12
11
import org .hibernate .metamodel .RepresentationMode ;
@@ -77,34 +76,6 @@ public interface Interceptor {
77
76
*/
78
77
default boolean onLoad (Object entity , Object id , Object [] state , String [] propertyNames , Type [] types )
79
78
throws CallbackException {
80
- if (id ==null || id instanceof Serializable ) {
81
- return onLoad (entity , (Serializable ) id , state , propertyNames , types );
82
- }
83
- return false ;
84
- }
85
-
86
- /**
87
- * Called just before an object is initialized. The interceptor may change the {@code state}, which will
88
- * be propagated to the persistent object. Note that when this method is called, {@code entity} will be
89
- * an empty uninitialized instance of the class.
90
- *
91
- * @apiNote The indexes across the {@code state}, {@code propertyNames}, and {@code types} arrays match.
92
- *
93
- * @param entity The entity instance being loaded
94
- * @param id The identifier value being loaded
95
- * @param state The entity state (which will be pushed into the entity instance)
96
- * @param propertyNames The names of the entity properties, corresponding to the {@code state}.
97
- * @param types The types of the entity properties, corresponding to the {@code state}.
98
- *
99
- * @return {@code true} if the user modified the {@code state} in any way.
100
- *
101
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
102
- *
103
- * @deprecated use {@link #onLoad(Object, Object, Object[], String[], Type[])}
104
- */
105
- @ Deprecated (since = "6.0" )
106
- default boolean onLoad (Object entity , Serializable id , Object [] state , String [] propertyNames , Type [] types )
107
- throws CallbackException {
108
79
return false ;
109
80
}
110
81
@@ -182,67 +153,6 @@ default boolean onFlushDirty(
182
153
Object [] previousState ,
183
154
String [] propertyNames ,
184
155
Type [] types ) throws CallbackException {
185
- if (id ==null || id instanceof Serializable ) {
186
- return onFlushDirty (entity , (Serializable ) id , currentState , previousState , propertyNames , types );
187
- }
188
- return false ;
189
- }
190
-
191
- /**
192
- * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected
193
- * {@code currentState}, which will be propagated to both the database and the persistent object.
194
- * Note that not all flushes end in actual synchronization with the database, in which case the
195
- * new {@code currentState} will be propagated to the object, but not necessarily (immediately) to
196
- * the database. It is strongly recommended that the interceptor <b>not</b> modify the {@code previousState}.
197
- *
198
- * @apiNote The indexes across the {@code currentState}, {@code previousState}, {@code propertyNames}, and
199
- * {@code types} arrays match.
200
- *
201
- * @param entity The entity instance detected as being dirty and being flushed
202
- * @param id The identifier of the entity
203
- * @param currentState The entity's current state
204
- * @param previousState The entity's previous (load time) state.
205
- * @param propertyNames The names of the entity properties
206
- * @param types The types of the entity properties
207
- *
208
- * @return {@code true} if the user modified the {@code currentState} in any way.
209
- *
210
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
211
- *
212
- * @deprecated use {@link #onFlushDirty(Object, Object, Object[], Object[], String[], Type[])}
213
- */
214
- @ Deprecated (since = "6.0" )
215
- default boolean onFlushDirty (
216
- Object entity ,
217
- Serializable id ,
218
- Object [] currentState ,
219
- Object [] previousState ,
220
- String [] propertyNames ,
221
- Type [] types ) throws CallbackException {
222
- return false ;
223
- }
224
-
225
- /**
226
- * Called before an object is made persistent by a stateful session.
227
- * <p>
228
- * The interceptor may modify the {@code state}, which will be used for
229
- * the SQL {@code INSERT} and propagated to the persistent object.
230
- *
231
- * @param entity The entity instance whose state is being inserted
232
- * @param id The identifier of the entity
233
- * @param state The state of the entity which will be inserted
234
- * @param propertyNames The names of the entity properties.
235
- * @param types The types of the entity properties
236
- *
237
- * @return {@code true} if the user modified the {@code state} in any way.
238
- *
239
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
240
- *
241
- * @deprecated use {@link #onSave(Object, Object, Object[], String[], Type[])}
242
- */
243
- @ Deprecated (since = "6.0" )
244
- default boolean onSave (Object entity , Serializable id , Object [] state , String [] propertyNames , Type [] types )
245
- throws CallbackException {
246
156
return false ;
247
157
}
248
158
@@ -270,31 +180,9 @@ default boolean onSave(Object entity, Serializable id, Object[] state, String[]
270
180
@ Deprecated (since = "6.6" )
271
181
default boolean onSave (Object entity , Object id , Object [] state , String [] propertyNames , Type [] types )
272
182
throws CallbackException {
273
- if (id ==null || id instanceof Serializable ) {
274
- return onSave (entity , (Serializable ) id , state , propertyNames , types );
275
- }
276
183
return false ;
277
184
}
278
185
279
- /**
280
- * Called before an object is removed by a stateful session.
281
- * <p>
282
- * It is not recommended that the interceptor modify the {@code state}.
283
- *
284
- * @param entity The entity instance being deleted
285
- * @param id The identifier of the entity
286
- * @param state The state of the entity
287
- * @param propertyNames The names of the entity properties.
288
- * @param types The types of the entity properties
289
- *
290
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
291
- *
292
- * @deprecated use {@link #onDelete(Object, Object, Object[], String[], Type[])}
293
- */
294
- @ Deprecated (since = "6.0" )
295
- default void onDelete (Object entity , Serializable id , Object [] state , String [] propertyNames , Type [] types )
296
- throws CallbackException {}
297
-
298
186
/**
299
187
* Called before an object is removed by a stateful session.
300
188
* <p>
@@ -315,24 +203,8 @@ default void onDelete(Object entity, Serializable id, Object[] state, String[] p
315
203
@ Deprecated (since = "6.6" )
316
204
default void onDelete (Object entity , Object id , Object [] state , String [] propertyNames , Type [] types )
317
205
throws CallbackException {
318
- if (id ==null || id instanceof Serializable ) {
319
- onDelete (entity , (Serializable ) id , state , propertyNames , types );
320
- }
321
206
}
322
207
323
- /**
324
- * Called before a collection is (re)created.
325
- *
326
- * @param collection The collection instance.
327
- * @param key The collection key value.
328
- *
329
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
330
- *
331
- * @deprecated use {@link #onCollectionRecreate(Object, Object)}
332
- */
333
- @ Deprecated (since = "6.0" )
334
- default void onCollectionRecreate (Object collection , Serializable key ) throws CallbackException {}
335
-
336
208
/**
337
209
* Called before a collection is (re)created.
338
210
*
@@ -342,24 +214,8 @@ default void onCollectionRecreate(Object collection, Serializable key) throws Ca
342
214
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
343
215
*/
344
216
default void onCollectionRecreate (Object collection , Object key ) throws CallbackException {
345
- if (key instanceof Serializable ) {
346
- onCollectionRecreate (collection , (Serializable ) key );
347
- }
348
217
}
349
218
350
- /**
351
- * Called before a collection is deleted.
352
- *
353
- * @param collection The collection instance.
354
- * @param key The collection key value.
355
- *
356
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
357
- *
358
- * @deprecated use {@link #onCollectionRemove(Object, Object)}
359
- */
360
- @ Deprecated (since = "6.0" )
361
- default void onCollectionRemove (Object collection , Serializable key ) throws CallbackException {}
362
-
363
219
/**
364
220
* Called before a collection is deleted.
365
221
*
@@ -369,24 +225,8 @@ default void onCollectionRemove(Object collection, Serializable key) throws Call
369
225
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
370
226
*/
371
227
default void onCollectionRemove (Object collection , Object key ) throws CallbackException {
372
- if (key instanceof Serializable ) {
373
- onCollectionRemove (collection , (Serializable ) key );
374
- }
375
228
}
376
229
377
- /**
378
- * Called before a collection is updated.
379
- *
380
- * @param collection The collection instance.
381
- * @param key The collection key value.
382
- *
383
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
384
- *
385
- * @deprecated use {@link #onCollectionUpdate(Object, Object)}
386
- */
387
- @ Deprecated (since = "6.0" )
388
- default void onCollectionUpdate (Object collection , Serializable key ) throws CallbackException {}
389
-
390
230
/**
391
231
* Called before a collection is updated.
392
232
*
@@ -396,9 +236,6 @@ default void onCollectionUpdate(Object collection, Serializable key) throws Call
396
236
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
397
237
*/
398
238
default void onCollectionUpdate (Object collection , Object key ) throws CallbackException {
399
- if (key instanceof Serializable ) {
400
- onCollectionUpdate (collection , (Serializable ) key );
401
- }
402
239
}
403
240
/**
404
241
* Called before a flush.
@@ -436,38 +273,6 @@ default Boolean isTransient(Object entity) {
436
273
return null ;
437
274
}
438
275
439
- /**
440
- * Called from {@code flush()}. The return value determines whether the entity is updated
441
- * <ul>
442
- * <li>an array of property indices - the entity is dirty
443
- * <li>an empty array - the entity is not dirty
444
- * <li>{@code null} - use Hibernate's default dirty-checking algorithm
445
- * </ul>
446
- *
447
- * @param entity The entity for which to find dirty properties.
448
- * @param id The identifier of the entity
449
- * @param currentState The current entity state as taken from the entity instance
450
- * @param previousState The state of the entity when it was last synchronized (generally when it was loaded)
451
- * @param propertyNames The names of the entity properties.
452
- * @param types The types of the entity properties
453
- *
454
- * @return array of dirty property indices or {@code null} to indicate Hibernate should perform default behaviour
455
- *
456
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
457
- *
458
- * @deprecated use {@link #findDirty(Object, Object, Object[], Object[], String[], Type[])}
459
- */
460
- @ Deprecated (since = "6.0" )
461
- default int [] findDirty (
462
- Object entity ,
463
- Serializable id ,
464
- Object [] currentState ,
465
- Object [] previousState ,
466
- String [] propertyNames ,
467
- Type [] types ) {
468
- return null ;
469
- }
470
-
471
276
/**
472
277
* Called from {@code flush()}. The return value determines whether the entity is updated
473
278
* <ul>
@@ -494,9 +299,6 @@ default int[] findDirty(
494
299
Object [] previousState ,
495
300
String [] propertyNames ,
496
301
Type [] types ) {
497
- if (id ==null || id instanceof Serializable ) {
498
- return findDirty (entity , (Serializable ) id , currentState , previousState , propertyNames , types );
499
- }
500
302
return null ;
501
303
}
502
304
@@ -539,23 +341,6 @@ default String getEntityName(Object object) throws CallbackException {
539
341
return null ;
540
342
}
541
343
542
- /**
543
- * Get a fully loaded entity instance that is cached externally.
544
- *
545
- * @param entityName the name of the entity
546
- * @param id the instance identifier
547
- *
548
- * @return a fully initialized entity
549
- *
550
- * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
551
- *
552
- * @deprecated use {@link #getEntity(String, Object)}
553
- */
554
- @ Deprecated (since = "6.0" )
555
- default Object getEntity (String entityName , Serializable id ) throws CallbackException {
556
- return null ;
557
- }
558
-
559
344
/**
560
345
* Get a fully loaded entity instance that is cached externally.
561
346
*
@@ -567,9 +352,6 @@ default Object getEntity(String entityName, Serializable id) throws CallbackExce
567
352
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
568
353
*/
569
354
default Object getEntity (String entityName , Object id ) throws CallbackException {
570
- if (id ==null || id instanceof Serializable ) {
571
- return getEntity (entityName , (Serializable ) id );
572
- }
573
355
return null ;
574
356
}
575
357
0 commit comments