Class SharedTableEntities

java.lang.Object
io.hypersistence.optimizer.hibernate.decorator.SharedTableEntities

public final class SharedTableEntities extends Object
The SharedTableEntities resolves, once per SessionFactory, the entities whose tables are also mapped by an entity belonging to a different hierarchy, as only those entities can trigger the TableRowAlreadyManagedEvent.

The session decorators check this before scanning the persistence context on every entity load. Otherwise, loading N entities in the same Session would take O(N^2) time, since each load would iterate over all the entities already managed by the persistence context.

The entity persisters are resolved reflectively, as the metamodel API differs between Hibernate versions.

Since:
2.14.0
Author:
Vlad Mihalcea
  • Method Details

    • isSharingTables

      public static boolean isSharingTables(Object sessionFactory, String entityName)
      Check whether the tables of the given entity are also mapped by an entity from a different hierarchy.
      Parameters:
      sessionFactory - the SessionFactory the entity persister belongs to
      entityName - the Hibernate entity name
      Returns:
      true if another entity hierarchy maps the same tables, or if the entity persisters could not be resolved