@@ -215,6 +215,7 @@ default void onCollectionRemove(Object collection, Object key) {
215
215
*/
216
216
default void onCollectionUpdate (Object collection , Object key ) {
217
217
}
218
+
218
219
/**
219
220
* Called before a flush.
220
221
*
@@ -223,32 +224,37 @@ default void onCollectionUpdate(Object collection, Object key) {
223
224
default void preFlush (Iterator <Object > entities ) {}
224
225
225
226
/**
226
- * Called after a flush that actually ends in execution of the SQL statements required to synchronize
227
- * in-memory state with the database.
227
+ * Called after a flush that actually ends in execution of the SQL statements
228
+ * required to synchronize in-memory state with the database.
228
229
*
229
230
* @param entities The entities that were flushed.
230
231
*/
231
232
default void postFlush (Iterator <Object > entities ) {}
232
233
233
234
/**
234
- * Called to distinguish between transient and detached entities. The return value determines the
235
- * state of the entity with respect to the current session.
235
+ * Called to distinguish between transient and detached entities. The return
236
+ * value determines the state of the entity with respect to the current session.
237
+ * This method should return:
236
238
* <ul>
237
- * <li>{@code Boolean.TRUE} - the entity is transient
238
- * <li>{@code Boolean.FALSE} - the entity is detached
239
- * <li>{@code null} - Hibernate uses the {@code unsaved-value} mapping and other heuristics to
240
- * determine if the object is unsaved
239
+ * <li>{@code Boolean.TRUE} if the entity is transient,
240
+ * <li>{@code Boolean.FALSE} if the entity is detached, or
241
+ * <li>{@code null} to signal that the usual heuristics should be used to determine
242
+ * if the instance is transient
241
243
* </ul>
244
+ * Heuristics used when this method returns null are based on the value of the
245
+ * {@linkplain jakarta.persistence.GeneratedValue generated} id field, or the
246
+ * {@linkplain jakarta.persistence.Version version} field, if any.
242
247
*
243
248
* @param entity a transient or detached entity
244
- * @return Boolean or {@code null} to choose default behaviour
249
+ * @return {@link Boolean} or {@code null} to choose default behaviour
245
250
*/
246
251
default Boolean isTransient (Object entity ) {
247
252
return null ;
248
253
}
249
254
250
255
/**
251
- * Called from {@code flush()}. The return value determines whether the entity is updated
256
+ * Called from {@code flush()}. The return value determines whether the entity
257
+ * is updated
252
258
* <ul>
253
259
* <li>an array of property indices - the entity is dirty
254
260
* <li>an empty array - the entity is not dirty
@@ -258,11 +264,13 @@ default Boolean isTransient(Object entity) {
258
264
* @param entity The entity for which to find dirty properties.
259
265
* @param id The identifier of the entity
260
266
* @param currentState The current entity state as taken from the entity instance
261
- * @param previousState The state of the entity when it was last synchronized (generally when it was loaded)
267
+ * @param previousState The state of the entity when it was last synchronized
268
+ * (generally when it was loaded)
262
269
* @param propertyNames The names of the entity properties.
263
270
* @param types The types of the entity properties
264
271
*
265
- * @return array of dirty property indices or {@code null} to indicate Hibernate should perform default behaviour
272
+ * @return array of dirty property indices or {@code null} to indicate Hibernate
273
+ * should perform default behaviour
266
274
*/
267
275
default int [] findDirty (
268
276
Object entity ,
@@ -275,9 +283,9 @@ default int[] findDirty(
275
283
}
276
284
277
285
/**
278
- * Instantiate the entity. Return {@code null} to indicate that Hibernate should use
279
- * the default constructor of the class. The identifier property of the returned instance
280
- * should be initialized with the given identifier.
286
+ * Instantiate the entity. Return {@code null} to indicate that Hibernate should
287
+ * use the default constructor of the class. The identifier property of the
288
+ * returned instance should be initialized with the given identifier.
281
289
*/
282
290
default Object instantiate (
283
291
String entityName ,
@@ -287,9 +295,9 @@ default Object instantiate(
287
295
}
288
296
289
297
/**
290
- * Instantiate the entity. Return {@code null} to indicate that Hibernate should use
291
- * the default constructor of the class. The identifier property of the returned instance
292
- * should be initialized with the given identifier.
298
+ * Instantiate the entity. Return {@code null} to indicate that Hibernate should
299
+ * use the default constructor of the class. The identifier property of the
300
+ * returned instance should be initialized with the given identifier.
293
301
*/
294
302
default Object instantiate (
295
303
String entityName ,
@@ -324,9 +332,10 @@ default Object getEntity(String entityName, Object id) {
324
332
}
325
333
326
334
/**
327
- * Called when a Hibernate transaction is begun via the Hibernate {@code Transaction}
328
- * API. Will not be called if transactions are being controlled via some other
329
- * mechanism (CMT, for example).
335
+ * Called when a Hibernate transaction is begun via the JPA-standard
336
+ * {@link jakarta.persistence.EntityTransaction} API, or via {@link Transaction}.
337
+ * This method is not be called if transactions are being controlled via some
338
+ * other mechanism, for example, if transactions are managed by a container.
330
339
*
331
340
* @param tx The Hibernate transaction facade object
332
341
*/
0 commit comments