Package org.hibernate.engine.internal
Class EntityEntryContext
java.lang.Object
org.hibernate.engine.internal.EntityEntryContext
Defines a context for maintaining the relation between an entity associated with the
Session
ultimately owning this EntityEntryContext
instance and that
entity's corresponding EntityEntry
. Two approaches are supported:-
the entity to
EntityEntry
association is maintained in a {code @Map} within this class, or -
the
EntityEntry
is injected into the entity via it implementing theManagedEntity
contract, either directly or through bytecode enhancement.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Used in building thereentrantSafeEntityEntries()
entries -
Constructor Summary
ConstructorsConstructorDescriptionEntityEntryContext
(PersistenceContext persistenceContext) Constructs a EntityEntryContext -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntityEntry
(Object entity, EntityEntry entityEntry) Adds the entity andEntityEntry
to this context, associating them.void
clear()
Clear this context of all managed entities.static EntityEntryContext
JDK serialization hook for deserializingvoid
Down-grade locks toLockMode.NONE
for all entities in this contextgetEntityEntry
(Object entity) Retrieve the associatedEntityEntry
for the given entity.int
boolean
hasEntityEntry
(Object entity) Does this entity exist in this context, associated with anEntityEntry
?The main bugaboo withIdentityMap
that warranted this class in the first place.removeEntityEntry
(Object entity) Remove an entity from the context, returning itsEntityEntry
.void
JDK serialization hook for serializing
-
Constructor Details
-
EntityEntryContext
Constructs a EntityEntryContext
-
-
Method Details
-
addEntityEntry
Adds the entity andEntityEntry
to this context, associating them.- Parameters:
entity
- The entityentityEntry
- The entry
-
hasEntityEntry
Does this entity exist in this context, associated with anEntityEntry
?- Parameters:
entity
- The entity to check- Returns:
true
if it is associated with this context
-
getEntityEntry
Retrieve the associatedEntityEntry
for the given entity.- Parameters:
entity
- The entity- Returns:
- The associated
EntityEntry
-
removeEntityEntry
Remove an entity from the context, returning itsEntityEntry
.- Parameters:
entity
- The entity to remove- Returns:
- The removed
EntityEntry
-
reentrantSafeEntityEntries
The main bugaboo withIdentityMap
that warranted this class in the first place.Return an array of all the entity/
EntityEntry
pairs in this context. The array is to make sure that the iterators built off of it are safe from concurrency/reentrancy.- Returns:
- The safe array
-
clear
public void clear()Clear this context of all managed entities. -
downgradeLocks
public void downgradeLocks()Down-grade locks toLockMode.NONE
for all entities in this context -
serialize
JDK serialization hook for serializing- Parameters:
oos
- The stream to write ourselves to- Throws:
IOException
- Indicates an IO exception accessing the given stream
-
deserialize
public static EntityEntryContext deserialize(ObjectInputStream ois, StatefulPersistenceContext rtn) throws IOException, ClassNotFoundException JDK serialization hook for deserializing- Parameters:
ois
- The stream to read ourselves fromrtn
- The persistence context we belong to- Returns:
- The deserialized EntityEntryContext
- Throws:
IOException
- Indicates an IO exception accessing the given streamClassNotFoundException
- Problem reading stream data
-
getNumberOfManagedEntities
public int getNumberOfManagedEntities()
-