Skip to content

Commit 48fc2ee

Browse files
committed
cleanups to EntityEntryContext javadoc
Signed-off-by: Gavin King <[email protected]>
1 parent 302dd29 commit 48fc2ee

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

hibernate-core/src/main/java/org/hibernate/engine/internal/EntityEntryContext.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@
3232
import static org.hibernate.engine.internal.ManagedTypeHelper.isManagedEntity;
3333

3434
/**
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>
3738
* <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
3941
* </li>
4042
* <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.
4345
* </li>
4446
* </ul>
4547
*
@@ -70,7 +72,7 @@ public EntityEntryContext(PersistenceContext persistenceContext) {
7072
}
7173

7274
/**
73-
* Adds the entity and entry to this context, associating them together
75+
* Adds the entity and {@link EntityEntry} to this context, associating them.
7476
*
7577
* @param entity The entity
7678
* @param entityEntry The entry
@@ -163,7 +165,8 @@ private ManagedEntity getAssociatedManagedEntity(Object entity) {
163165
// it is not associated
164166
return null;
165167
}
166-
final AbstractEntityEntry entityEntry = (AbstractEntityEntry) managedEntity.$$_hibernate_getEntityEntry();
168+
final AbstractEntityEntry entityEntry =
169+
(AbstractEntityEntry) managedEntity.$$_hibernate_getEntityEntry();
167170

168171
if ( entityEntry.getPersister().isMutable() ) {
169172
return entityEntry.getPersistenceContext() == persistenceContext
@@ -209,7 +212,7 @@ private void checkNotAssociatedWithOtherPersistenceContextIfMutable(ManagedEntit
209212
}
210213

211214
/**
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}?
213216
*
214217
* @param entity The entity to check
215218
*
@@ -220,28 +223,27 @@ public boolean hasEntityEntry(Object entity) {
220223
}
221224

222225
/**
223-
* Retrieve the associated EntityEntry for the entity
226+
* Retrieve the associated {@link EntityEntry} for the given entity.
224227
*
225-
* @param entity The entity to retrieve the EntityEntry for
228+
* @param entity The entity
226229
*
227-
* @return The associated EntityEntry
230+
* @return The associated {@link EntityEntry}
228231
*/
229232
public EntityEntry getEntityEntry(Object entity) {
230233
// locate a ManagedEntity for the entity, but only if it is associated with the same PersistenceContext.
231234
final ManagedEntity managedEntity = getAssociatedManagedEntity( entity );
232-
233235
// and get/return the EntityEntry from the ManagedEntry
234236
return managedEntity == null
235237
? null
236238
: managedEntity.$$_hibernate_getEntityEntry();
237239
}
238240

239241
/**
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}.
241243
*
242244
* @param entity The entity to remove
243245
*
244-
* @return Tjee EntityEntry
246+
* @return The removed {@link EntityEntry}
245247
*/
246248
public EntityEntry removeEntityEntry(Object entity) {
247249
// locate a ManagedEntity for the entity, but only if it is associated with the same PersistenceContext.
@@ -308,10 +310,12 @@ else if ( ! ( isManagedEntity( entity ) ) ) {
308310
}
309311

310312
/**
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.
315319
*
316320
* @return The safe array
317321
*/
@@ -366,7 +370,7 @@ private static void unsetSession(PersistentAttributeInterceptable persistentAttr
366370
}
367371

368372
/**
369-
* Clear this context of all managed entities
373+
* Clear this context of all managed entities.
370374
*/
371375
public void clear() {
372376
dirty = true;
@@ -395,7 +399,7 @@ private static void clearManagedEntity(final ManagedEntity node) {
395399
}
396400

397401
/**
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
399403
*/
400404
public void downgradeLocks() {
401405
processEachManagedEntity( EntityEntryContext::downgradeLockOnManagedEntity );
@@ -546,7 +550,7 @@ public int getNumberOfManagedEntities() {
546550
}
547551

548552
/**
549-
* The wrapper for entity classes which do not implement ManagedEntity
553+
* The wrapper for entity classes which do not implement {@link ManagedEntity}.
550554
*/
551555
private static class ManagedEntityImpl implements ManagedEntity {
552556
private final Object entityInstance;
@@ -685,9 +689,8 @@ public ImmutableManagedEntityHolder(ManagedEntity immutableManagedEntity) {
685689
return managedEntity.$$_hibernate_useTracker();
686690
}
687691

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
691694
private boolean canClearEntityEntryReference() {
692695
EntityEntry entityEntry = managedEntity.$$_hibernate_getEntityEntry();
693696
return !(entityEntry instanceof ImmutableEntityEntry)

0 commit comments

Comments
 (0)