Class EntityEntryContext

  • public class EntityEntryContext
    extends Object
    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. 2 approaches are supported:
    • the entity->EntityEntry association is maintained in a Map within this class
    • the EntityEntry is injected into the entity via it implementing the ManagedEntity contract, either directly or through bytecode enhancement.

    • Constructor Detail

      • EntityEntryContext

        public EntityEntryContext​(PersistenceContext persistenceContext)
        Constructs a EntityEntryContext
    • Method Detail

      • addEntityEntry

        public void addEntityEntry​(Object entity,
                                   EntityEntry entityEntry)
        Adds the entity and entry to this context, associating them together
        entity - The entity
        entityEntry - The entry
      • hasEntityEntry

        public boolean hasEntityEntry​(Object entity)
        Does this entity exist in this context, associated with an EntityEntry?
        entity - The entity to check
        true if it is associated with this context
      • getEntityEntry

        public EntityEntry getEntityEntry​(Object entity)
        Retrieve the associated EntityEntry for the entity
        entity - The entity to retrieve the EntityEntry for
        The associated EntityEntry
      • removeEntityEntry

        public EntityEntry removeEntityEntry​(Object entity)
        Remove an entity from the context, returning the EntityEntry which was associated with it
        entity - The entity to remove
        Tjee EntityEntry
      • reentrantSafeEntityEntries

        public Map.Entry<Object,​EntityEntry>[] reentrantSafeEntityEntries()
        The main bugaboo with IdentityMap 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
        The safe array
      • processEachEntity

        public void processEachEntity​(Consumer<Object> entityProcessor)
        Not reentrant like #reentrantSafeEntityEntries but most likely the more efficient choice, when reentrant safety isn't required.
      • clear

        public void clear()
        Clear this context of all managed entities
      • downgradeLocks

        public void downgradeLocks()
        Down-grade locks to NONE for all entities in this context
      • serialize

        public void serialize​(ObjectOutputStream oos)
                       throws IOException
        JDK serialization hook for serializing
        oos - The stream to write ourselves to
        IOException - Indicates an IO exception accessing the given stream
      • getNumberOfManagedEntities

        public int getNumberOfManagedEntities()