Package org.hibernate.loader.plan.spi

Examples of org.hibernate.loader.plan.spi.EntityReference


    final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph();
    if ( indexGraph != null ) {
      printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection index) " );

      if ( EntityReference.class.isInstance( indexGraph ) ) {
        final EntityReference indexGraphAsEntityReference = (EntityReference) indexGraph;
        printWriter.println( extractDetails( indexGraphAsEntityReference ) );
        writeEntityReferenceFetches( indexGraphAsEntityReference, depth+1, printWriter );
      }
      else if ( CompositeFetch.class.isInstance( indexGraph ) ) {
        final CompositeFetch indexGraphAsCompositeFetch = (CompositeFetch) indexGraph;
        printWriter.println( extractDetails( indexGraphAsCompositeFetch ) );
        writeCompositeFetchFetches( indexGraphAsCompositeFetch, depth+1, printWriter );
      }
    }

    final CollectionFetchableElement elementGraph = collectionReference.getElementGraph();
    if ( elementGraph != null ) {
      printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection element) " );

      if ( EntityReference.class.isInstance( elementGraph ) ) {
        final EntityReference elementGraphAsEntityReference = (EntityReference) elementGraph;
        printWriter.println( extractDetails( elementGraphAsEntityReference ) );
        writeEntityReferenceFetches( elementGraphAsEntityReference, depth+1, printWriter );
      }
      else if ( CompositeFetch.class.isInstance( elementGraph ) ) {
        final CompositeFetch elementGraphAsCompositeFetch = (CompositeFetch) elementGraph;
View Full Code Here


              fetchSource
          )
      );
    }

    final EntityReference entityReference = (EntityReference) fetchSource;
    // NOTE : this is not the most exhaustive of checks because of hierarchical associations (employee/manager)
    if ( ! entityReference.getEntityPersister().equals( entityDefinition.getEntityPersister() ) ) {
      throw new WalkingException( "Mismatched FetchSource from stack on pop" );
    }
  }
View Full Code Here

        "%s Starting entity identifier : %s",
        StringHelper.repeat( ">>", fetchSourceStack.size() ),
        entityIdentifierDefinition.getEntityDefinition().getEntityPersister().getEntityName()
    );

    final EntityReference entityReference = (EntityReference) currentSource();

    // perform some stack validation
    if ( ! entityReference.getEntityPersister().equals( entityIdentifierDefinition.getEntityDefinition().getEntityPersister() ) ) {
      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()
          )
      );
    }

    if ( ExpandingEntityIdentifierDescription.class.isInstance( entityReference.getIdentifierDescription() ) ) {
      pushToStack( (ExpandingEntityIdentifierDescription) entityReference.getIdentifierDescription() );
    }
  }
View Full Code Here

    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 ) {
      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()
          )
      );
    }
View Full Code Here

    this.readerCollector = new CollectionLoaderReaderCollectorImpl(
        new CollectionReturnReader( rootReturn ),
        new CollectionReferenceInitializerImpl( rootReturn, collectionReferenceAliases )
    );
    if ( rootReturn.getCollectionPersister().getElementType().isEntityType() ) {
      final EntityReference elementEntityReference = rootReturn.getElementGraph().resolveEntityReference();
      readerCollector.add(
        new EntityReferenceInitializerImpl( elementEntityReference, collectionReferenceAliases.getEntityElementAliases() )
      );
    }
    if ( rootReturn.getCollectionPersister().hasIndex() &&
        rootReturn.getCollectionPersister().getIndexType().isEntityType() ) {
      final EntityReference indexEntityReference = rootReturn.getIndexGraph().resolveEntityReference();
      final EntityReferenceAliases indexEntityReferenceAliases = aliasResolutionContext.generateEntityReferenceAliases(
          indexEntityReference.getQuerySpaceUid(),
          indexEntityReference.getEntityPersister()
      );
      readerCollector.add(
          new EntityReferenceInitializerImpl( indexEntityReference, indexEntityReferenceAliases )
      );
    }
View Full Code Here

  @Override
  protected  void applyRootReturnSelectFragments(SelectStatementBuilder selectStatementBuilder) {
    if ( getQueryableCollection().hasIndex() &&
        getQueryableCollection().getIndexType().isEntityType() ) {
      final EntityReference indexEntityReference = getRootCollectionReturn().getIndexGraph().resolveEntityReference();
      final EntityReferenceAliases indexEntityReferenceAliases = getAliasResolutionContext().resolveEntityReferenceAliases(
          indexEntityReference.getQuerySpaceUid()
      );
      selectStatementBuilder.appendSelectClauseFragment(
          ( (OuterJoinLoadable) indexEntityReference.getEntityPersister() ).selectFragment(
              indexEntityReferenceAliases.getTableAlias(),
              indexEntityReferenceAliases.getColumnAliases().getSuffix()
          )
      );
    }
View Full Code Here

  private void resolveEntityKey(
      ResultSet resultSet,
      ResultSetProcessingContextImpl context,
      EntityReferenceInitializer entityReferenceInitializer,
      Map<EntityReference,EntityReferenceInitializer> initializerByEntityReference) throws SQLException {
    final EntityReference entityReference = entityReferenceInitializer.getEntityReference();
    final EntityIdentifierDescription identifierDescription = entityReference.getIdentifierDescription();

    if ( identifierDescription.hasFetches() || identifierDescription.hasBidirectionalEntityReferences() ) {
      resolveEntityKey( resultSet, context, (FetchSource) identifierDescription, initializerByEntityReference );
    }
    entityReferenceInitializer.resolveEntityKey( resultSet, context );
View Full Code Here

    // if the fetchSource is an entityReference, we should also walk its identifier fetches here...
    //
    // what if fetchSource is a composite fetch (as it would be in the case of a key-many-to-one)?
    if ( EntityReference.class.isInstance( fetchSource ) ) {
      final EntityReference fetchOwnerAsEntityReference = (EntityReference) fetchSource;
      if ( fetchOwnerAsEntityReference.getIdentifierDescription().hasFetches() ) {
        final FetchSource entityIdentifierAsFetchSource = (FetchSource) fetchOwnerAsEntityReference.getIdentifierDescription();
        for ( Fetch fetch : entityIdentifierAsFetchSource.getFetches() ) {
          processFetch(
              selectStatementBuilder,
              fetchSource,
              fetch,
View Full Code Here

    // if the fetchSource is an entityReference, we should also walk its identifier fetches here...
    //
    // what if fetchSource is a composite fetch (as it would be in the case of a key-many-to-one)?
    if ( EntityReference.class.isInstance( fetchSource ) ) {
      final EntityReference fetchOwnerAsEntityReference = (EntityReference) fetchSource;
      if ( fetchOwnerAsEntityReference.getIdentifierDescription().hasFetches() ) {
        final FetchSource entityIdentifierAsFetchSource = (FetchSource) fetchOwnerAsEntityReference.getIdentifierDescription();
        for ( Fetch fetch : entityIdentifierAsFetchSource.getFetches() ) {
          processFetch(
              selectStatementBuilder,
              fetchSource,
              fetch,
View Full Code Here

      final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph();
      if ( indexGraph != null ) {
        printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection index) " );

        if ( EntityReference.class.isInstance( indexGraph ) ) {
          final EntityReference indexGraphAsEntityReference = (EntityReference) indexGraph;
          printWriter.println( extractDetails( indexGraphAsEntityReference ) );
          writeEntityReferenceFetches( indexGraphAsEntityReference, depth+1, printWriter );
        }
        else if ( CompositeFetch.class.isInstance( indexGraph ) ) {
          final CompositeFetch indexGraphAsCompositeFetch = (CompositeFetch) indexGraph;
          printWriter.println( extractDetails( indexGraphAsCompositeFetch ) );
          writeCompositeFetchFetches( indexGraphAsCompositeFetch, depth+1, printWriter );
        }
      }
    }

    final CollectionFetchableElement elementGraph = collectionReference.getElementGraph();
    if ( elementGraph != null ) {
      printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection element) " );

      if ( EntityReference.class.isInstance( elementGraph ) ) {
        final EntityReference elementGraphAsEntityReference = (EntityReference) elementGraph;
        printWriter.println( extractDetails( elementGraphAsEntityReference ) );
        writeEntityReferenceFetches( elementGraphAsEntityReference, depth+1, printWriter );
      }
      else if ( CompositeFetch.class.isInstance( elementGraph ) ) {
        final CompositeFetch elementGraphAsCompositeFetch = (CompositeFetch) elementGraph;
View Full Code Here

TOP

Related Classes of org.hibernate.loader.plan.spi.EntityReference

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.