Package org.hibernate.loader.plan.build.spi

Examples of org.hibernate.loader.plan.build.spi.ExpandingFetchSource


    propertyPathStack.push( fetchSource.getPropertyPath() );
    fetchSourceStack.addFirst( fetchSource );
  }

  private ExpandingFetchSource popFromStack() {
    final ExpandingFetchSource last = fetchSourceStack.removeFirst();
    log.trace( "Popped fetch owner from stack : " + last );
    propertyPathStack.pop();
    return last;
  }
View Full Code Here


      // if not, this call should represent a fetch which will be handled in #finishingAttribute
      return;
    }

    // if we get here, it is a root
    final ExpandingFetchSource popped = popFromStack();
    checkPoppedEntity( popped, entityDefinition );

    log.tracef(
        "%s Finished root entity : %s",
        StringHelper.repeat( "<<", fetchSourceStack.size() ),
View Full Code Here

  }

  @Override
  public void finishingEntityIdentifier(EntityIdentifierDefinition entityIdentifierDefinition) {
    // only pop from stack if the current source is ExpandingEntityIdentifierDescription..
    final ExpandingFetchSource currentSource = currentSource();
    if ( ! ExpandingEntityIdentifierDescription.class.isInstance( currentSource ) ) {
      // in this case, the current source should be the entity that owns entityIdentifierDefinition
      if ( ! EntityReference.class.isInstance( currentSource ) ) {
        throw new WalkingException( "Unexpected state in FetchSource stack" );
      }
      final EntityReference entityReference = (EntityReference) currentSource;
      if ( entityReference.getEntityPersister().getEntityKeyDefinition() != entityIdentifierDefinition ) {
        throw new WalkingException(
            String.format(
                "Encountered unexpected fetch owner [%s] in stack while processing entity identifier for [%s]",
                entityReference.getEntityPersister().getEntityName(),
                entityIdentifierDefinition.getEntityDefinition().getEntityPersister().getEntityName()
            )
        );
      }
      return;
    }

    // the current source is ExpandingEntityIdentifierDescription...
    final ExpandingEntityIdentifierDescription identifierDescription =
        (ExpandingEntityIdentifierDescription) popFromStack();

    // and then on the node before it (which should be the entity that owns the identifier being described)
    final ExpandingFetchSource entitySource = currentSource();
    if ( ! EntityReference.class.isInstance( entitySource ) ) {
      throw new WalkingException( "Unexpected state in FetchSource stack" );
    }
    final EntityReference entityReference = (EntityReference) entitySource;
    if ( entityReference.getIdentifierDescription() != identifierDescription ) {
View Full Code Here

    if ( indexType.isAnyType() ) {
      // nothing to do because the index graph was not pushed in #startingCollectionIndex.
    }
    else if ( indexType.isEntityType() || indexType.isComponentType() ) {
      // todo : validate the stack?
      final ExpandingFetchSource fetchSource = popFromStack();
      if ( !CollectionFetchableIndex.class.isInstance( fetchSource ) ) {
        throw new WalkingException(
            "CollectionReference did not return an expected index graph : " +
                indexDefinition.getCollectionDefinition().getCollectionPersister().getRole()
        );
View Full Code Here

    if ( elementType.isAnyType() ) {
      // nothing to do because the element graph was not pushed in #startingCollectionElement..
    }
    else if ( elementType.isComponentType() || elementType.isAssociationType()) {
      // pop it from the stack
      final ExpandingFetchSource popped = popFromStack();

      // validation
      if ( ! CollectionFetchableElement.class.isInstance( popped ) ) {
        throw new WalkingException( "Mismatched FetchSource from stack on pop" );
      }
View Full Code Here

          (AssociationAttributeDefinition) attributeDefinition;
      if ( attributeType.isAnyType() ) {
        // Nothing to do because AnyFetch does not implement ExpandingFetchSource (i.e., it cannot be pushed/popped).
      }
      else if ( attributeType.isEntityType() ) {
        final ExpandingFetchSource source = currentSource();
        // One way to find out if the fetch was pushed is to check the fetch strategy; rather than recomputing
        // the fetch strategy, simply check if current source's fetched attribute definition matches
        // associationAttributeDefinition.
        if ( AttributeFetch.class.isInstance( source ) &&
            associationAttributeDefinition.equals( AttributeFetch.class.cast( source ).getFetchedAttributeDefinition() ) ) {
          final ExpandingFetchSource popped = popFromStack();
          checkPoppedEntity( popped, associationAttributeDefinition.toEntityDefinition() );
        }
      }
      else if ( attributeType.isCollectionType() ) {
        final CollectionReference currentCollection = currentCollection();
        // One way to find out if the fetch was pushed is to check the fetch strategy; rather than recomputing
        // the fetch strategy, simply check if current collection's fetched attribute definition matches
        // associationAttributeDefinition.
        if ( AttributeFetch.class.isInstance( currentCollection ) &&
            associationAttributeDefinition.equals( AttributeFetch.class.cast( currentCollection ).getFetchedAttributeDefinition() ) ) {
          final CollectionReference popped = popFromCollectionStack();
          checkedPoppedCollection( popped, associationAttributeDefinition.toCollectionDefinition() );
        }
      }
    }
    else if ( attributeType.isComponentType() ) {
      // CompositeFetch is always pushed, during #startingAttribute(),
      // so pop the current fetch owner, and make sure what we just popped represents this composition
      final ExpandingFetchSource popped = popFromStack();
      if ( !CompositeAttributeFetch.class.isInstance( popped ) ) {
        throw new WalkingException(
            String.format(
                "Mismatched FetchSource from stack on pop; expected: CompositeAttributeFetch; actual: [%s]",
                popped
View Full Code Here

    final FetchStrategy fetchStrategy = determineFetchStrategy( attributeDefinition );
    if ( fetchStrategy.getTiming() != FetchTiming.IMMEDIATE ) {
      return false;
    }

    final ExpandingFetchSource currentSource = currentSource();
    currentSource.validateFetchPlan( fetchStrategy, attributeDefinition );

    final AssociationAttributeDefinition.AssociationNature nature = attributeDefinition.getAssociationNature();
    if ( nature == AssociationAttributeDefinition.AssociationNature.ANY ) {
      // for ANY mappings we need to build a Fetch:
      //    1) fetch type is SELECT
      //    2) (because the fetch cannot be a JOIN...) do not push it to the stack
      currentSource.buildAnyAttributeFetch(
          attributeDefinition,
          fetchStrategy
      );
      return false;
    }
    else if ( nature == AssociationAttributeDefinition.AssociationNature.ENTITY ) {
      EntityFetch fetch = currentSource.buildEntityAttributeFetch(
          attributeDefinition,
          fetchStrategy
      );
      if ( fetchStrategy.getStyle() == FetchStyle.JOIN ) {
        pushToStack( (ExpandingFetchSource) fetch );
        return true;
      }
      else {
        return false;
      }
    }
    else {
      // Collection
      CollectionAttributeFetch fetch = currentSource.buildCollectionAttributeFetch( attributeDefinition, fetchStrategy );
      if ( fetchStrategy.getStyle() == FetchStyle.JOIN ) {
        pushToCollectionStack( fetch );
        return true;
      }
      else {
View Full Code Here

    propertyPathStack.push( fetchSource.getPropertyPath() );
    fetchSourceStack.addFirst( fetchSource );
  }

  private ExpandingFetchSource popFromStack() {
    final ExpandingFetchSource last = fetchSourceStack.removeFirst();
    log.trace( "Popped fetch owner from stack : " + last );
    propertyPathStack.pop();
    return last;
  }
View Full Code Here

      // if not, this call should represent a fetch which will be handled in #finishingAttribute
      return;
    }

    // if we get here, it is a root
    final ExpandingFetchSource popped = popFromStack();
    checkPoppedEntity( popped, entityDefinition );

    log.tracef(
        "%s Finished root entity : %s",
        StringHelper.repeat( "<<", fetchSourceStack.size() ),
View Full Code Here

  }

  @Override
  public void finishingEntityIdentifier(EntityIdentifierDefinition entityIdentifierDefinition) {
    // only pop from stack if the current source is ExpandingEntityIdentifierDescription..
    final ExpandingFetchSource currentSource = currentSource();
    if ( ! ExpandingEntityIdentifierDescription.class.isInstance( currentSource ) ) {
      // in this case, the current source should be the entity that owns entityIdentifierDefinition
      if ( ! EntityReference.class.isInstance( currentSource ) ) {
        throw new WalkingException( "Unexpected state in FetchSource stack" );
      }
      final EntityReference entityReference = (EntityReference) currentSource;
      if ( entityReference.getEntityPersister().getEntityKeyDefinition() != entityIdentifierDefinition ) {
        throw new WalkingException(
            String.format(
                "Encountered unexpected fetch owner [%s] in stack while processing entity identifier for [%s]",
                entityReference.getEntityPersister().getEntityName(),
                entityIdentifierDefinition.getEntityDefinition().getEntityPersister().getEntityName()
            )
        );
      }
      return;
    }

    // the current source is ExpandingEntityIdentifierDescription...
    final ExpandingEntityIdentifierDescription identifierDescription =
        (ExpandingEntityIdentifierDescription) popFromStack();

    // and then on the node before it (which should be the entity that owns the identifier being described)
    final ExpandingFetchSource entitySource = currentSource();
    if ( ! EntityReference.class.isInstance( entitySource ) ) {
      throw new WalkingException( "Unexpected state in FetchSource stack" );
    }
    final EntityReference entityReference = (EntityReference) entitySource;
    if ( entityReference.getIdentifierDescription() != identifierDescription ) {
View Full Code Here

TOP

Related Classes of org.hibernate.loader.plan.build.spi.ExpandingFetchSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.