32
32
import static org .hibernate .engine .internal .ManagedTypeHelper .isManagedEntity ;
33
33
34
34
/**
35
- * Defines a context for maintaining the relation between an entity associated with the Session ultimately owning this
36
- * EntityEntryContext instance and that entity's corresponding EntityEntry. 2 approaches are supported:<ul>
35
+ * Defines a context for maintaining the relation between an entity associated with the
36
+ * {@code Session} ultimately owning this {@code EntityEntryContext} instance and that
37
+ * entity's corresponding {@link EntityEntry}. Two approaches are supported:<ul>
37
38
* <li>
38
- * the entity->EntityEntry association is maintained in a Map within this class
39
+ * the entity to {@link EntityEntry} association is maintained in a {code @Map}
40
+ * within this class, or
39
41
* </li>
40
42
* <li>
41
- * the EntityEntry is injected into the entity via it implementing the {@link ManagedEntity} contract,
42
- * either directly or through bytecode enhancement.
43
+ * the {@link EntityEntry} is injected into the entity via it implementing the
44
+ * {@link ManagedEntity} contract, either directly or through bytecode enhancement.
43
45
* </li>
44
46
* </ul>
45
47
*
@@ -70,7 +72,7 @@ public EntityEntryContext(PersistenceContext persistenceContext) {
70
72
}
71
73
72
74
/**
73
- * Adds the entity and entry to this context, associating them together
75
+ * Adds the entity and {@link EntityEntry} to this context, associating them.
74
76
*
75
77
* @param entity The entity
76
78
* @param entityEntry The entry
@@ -163,7 +165,8 @@ private ManagedEntity getAssociatedManagedEntity(Object entity) {
163
165
// it is not associated
164
166
return null ;
165
167
}
166
- final AbstractEntityEntry entityEntry = (AbstractEntityEntry ) managedEntity .$$_hibernate_getEntityEntry ();
168
+ final AbstractEntityEntry entityEntry =
169
+ (AbstractEntityEntry ) managedEntity .$$_hibernate_getEntityEntry ();
167
170
168
171
if ( entityEntry .getPersister ().isMutable () ) {
169
172
return entityEntry .getPersistenceContext () == persistenceContext
@@ -209,7 +212,7 @@ private void checkNotAssociatedWithOtherPersistenceContextIfMutable(ManagedEntit
209
212
}
210
213
211
214
/**
212
- * Does this entity exist in this context, associated with an EntityEntry?
215
+ * Does this entity exist in this context, associated with an {@link EntityEntry} ?
213
216
*
214
217
* @param entity The entity to check
215
218
*
@@ -220,28 +223,27 @@ public boolean hasEntityEntry(Object entity) {
220
223
}
221
224
222
225
/**
223
- * Retrieve the associated EntityEntry for the entity
226
+ * Retrieve the associated {@link EntityEntry} for the given entity.
224
227
*
225
- * @param entity The entity to retrieve the EntityEntry for
228
+ * @param entity The entity
226
229
*
227
- * @return The associated EntityEntry
230
+ * @return The associated {@link EntityEntry}
228
231
*/
229
232
public EntityEntry getEntityEntry (Object entity ) {
230
233
// locate a ManagedEntity for the entity, but only if it is associated with the same PersistenceContext.
231
234
final ManagedEntity managedEntity = getAssociatedManagedEntity ( entity );
232
-
233
235
// and get/return the EntityEntry from the ManagedEntry
234
236
return managedEntity == null
235
237
? null
236
238
: managedEntity .$$_hibernate_getEntityEntry ();
237
239
}
238
240
239
241
/**
240
- * Remove an entity from the context, returning the EntityEntry which was associated with it
242
+ * Remove an entity from the context, returning its {@link EntityEntry}.
241
243
*
242
244
* @param entity The entity to remove
243
245
*
244
- * @return Tjee EntityEntry
246
+ * @return The removed {@link EntityEntry}
245
247
*/
246
248
public EntityEntry removeEntityEntry (Object entity ) {
247
249
// locate a ManagedEntity for the entity, but only if it is associated with the same PersistenceContext.
@@ -308,10 +310,12 @@ else if ( ! ( isManagedEntity( entity ) ) ) {
308
310
}
309
311
310
312
/**
311
- * The main bugaboo with IdentityMap that warranted this class in the first place.
312
- *
313
- * Return an array of all the entity/EntityEntry pairs in this context. The array is to make sure
314
- * that the iterators built off of it are safe from concurrency/reentrancy
313
+ * The main bugaboo with {@code IdentityMap} that warranted this class in the
314
+ * first place.
315
+ * <p>
316
+ * Return an array of all the entity/{@link EntityEntry} pairs in this context.
317
+ * The array is to make sure that the iterators built off of it are safe from
318
+ * concurrency/reentrancy.
315
319
*
316
320
* @return The safe array
317
321
*/
@@ -366,7 +370,7 @@ private static void unsetSession(PersistentAttributeInterceptable persistentAttr
366
370
}
367
371
368
372
/**
369
- * Clear this context of all managed entities
373
+ * Clear this context of all managed entities.
370
374
*/
371
375
public void clear () {
372
376
dirty = true ;
@@ -395,7 +399,7 @@ private static void clearManagedEntity(final ManagedEntity node) {
395
399
}
396
400
397
401
/**
398
- * Down-grade locks to NONE for all entities in this context
402
+ * Down-grade locks to {@link LockMode# NONE} for all entities in this context
399
403
*/
400
404
public void downgradeLocks () {
401
405
processEachManagedEntity ( EntityEntryContext ::downgradeLockOnManagedEntity );
@@ -546,7 +550,7 @@ public int getNumberOfManagedEntities() {
546
550
}
547
551
548
552
/**
549
- * The wrapper for entity classes which do not implement ManagedEntity
553
+ * The wrapper for entity classes which do not implement {@link ManagedEntity}.
550
554
*/
551
555
private static class ManagedEntityImpl implements ManagedEntity {
552
556
private final Object entityInstance ;
@@ -685,9 +689,8 @@ public ImmutableManagedEntityHolder(ManagedEntity immutableManagedEntity) {
685
689
return managedEntity .$$_hibernate_useTracker ();
686
690
}
687
691
688
- /*
689
- Check instance type of EntityEntry and if type is ImmutableEntityEntry, check to see if entity is referenced cached in the second level cache
690
- */
692
+ // Check instance type of EntityEntry and if type is ImmutableEntityEntry,
693
+ // check to see if entity is referenced cached in the second level cache
691
694
private boolean canClearEntityEntryReference () {
692
695
EntityEntry entityEntry = managedEntity .$$_hibernate_getEntityEntry ();
693
696
return !(entityEntry instanceof ImmutableEntityEntry )
0 commit comments