Class MetamodelGraphWalker


  • public class MetamodelGraphWalker
    extends java.lang.Object
    Implements metamodel graph walking. In layman terms, we are walking the graph of the users domain model as defined/understood by mapped associations.

    Initially grew as a part of the re-implementation of the legacy JoinWalker functionality to instead build LoadPlans. But this is really quite simple walking. Interesting events are handled by calling out to implementations of AssociationVisitationStrategy which really provide the real functionality of what we do as we walk.

    The visitor will walk the entire metamodel graph (the parts reachable from the given root)!!! It is up to the provided AssociationVisitationStrategy to tell it when to stop. The walker provides the walking; the strategy provides the semantics of what happens at certain points. Its really very similar to parsers and how parsing is generally split between syntax and semantics. Walker walks the syntax (associations, identifiers, etc) and when it calls out to the strategy the strategy then decides the semantics (literally, the meaning).

    The visitor will, however, stop if it sees a "duplicate" AssociationKey. In such a case, the walker would call AssociationVisitationStrategy.foundCircularAssociation(org.hibernate.persister.walking.spi.AssociationAttributeDefinition) and stop walking any further down that graph any further.

    • Method Detail

      • visitEntity

        public static void visitEntity​(AssociationVisitationStrategy strategy,
                                       EntityPersister persister)
        Entry point into walking the model graph of an entity according to its defined metamodel.
        Parameters:
        strategy - The semantics strategy
        persister - The persister describing the entity to start walking from
      • visitCollection

        public static void visitCollection​(AssociationVisitationStrategy strategy,
                                           CollectionPersister persister)
        Entry point into walking the model graph of a collection according to its defined metamodel.
        Parameters:
        strategy - The semantics strategy
        persister - The persister describing the collection to start walking from
      • addAssociationKey

        protected void addAssociationKey​(AssociationKey associationKey)
        Add association key to indicate the association is being visited.
        Parameters:
        associationKey - - the association key.
        Throws:
        WalkingException - if the association with the specified association key has already been visited.
      • isDuplicateAssociationKey

        protected boolean isDuplicateAssociationKey​(AssociationKey associationKey)
        Has an association with the specified key been visited already?
        Parameters:
        associationKey - - the association key.
        Returns:
        true, if the association with the specified association key has already been visited; false, otherwise.