Package org.hibernate.loader.plan2.exec.process.internal

Examples of org.hibernate.loader.plan2.exec.process.internal.EntityReferenceInitializerImpl


      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" );
    }

    log.tracef(
        "%s Finished entity : %s",
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()
          )
      );
    }

    // todo : handle AssociationKeys here?  is that why we get the duplicate joins and fetches?

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

    // 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

    // also add an AssociationKey for the root so we can later on recognize circular references back to the root.
    // for a collection, the circularity would always be to an entity element...
    if ( collectionReturn.getElementGraph() != null ) {
      if ( EntityReference.class.isInstance( collectionReturn.getElementGraph() ) ) {
        final EntityReference entityReference = (EntityReference) collectionReturn.getElementGraph();
        final Joinable entityPersister = (Joinable) entityReference.getEntityPersister();
        associationKeyRegistered(
            new AssociationKey( entityPersister.getTableName(), entityPersister.getKeyColumnNames() )
        );
      }
    }
View Full Code Here

    //   2) Determine how to read information out of the ResultSet resulting from executing the indicated SQL
    //    (the SQL aliases).  ReaderCollector and friends are where this work happens, ultimately
    //    producing a ResultSetProcessor

    final SelectStatementBuilder select = new SelectStatementBuilder( factory.getDialect() );
    final EntityReturn rootReturn = Helper.INSTANCE.extractRootReturn( loadPlan, EntityReturn.class );
    final ReaderCollectorImpl readerCollector = new ReaderCollectorImpl();

    final LoadQueryJoinAndFetchProcessor helper = new LoadQueryJoinAndFetchProcessor( aliasResolutionContext , buildingParameters, factory );

    final String[] keyColumnNamesToUse = keyColumnNames != null
        ? keyColumnNames
        : ( (Queryable) rootReturn.getEntityPersister() ).getIdentifierColumnNames();

    // LoadPlan is broken down into 2 high-level pieces that we need to process here.
    //
    // First is the QuerySpaces, which roughly equates to the SQL FROM-clause.  We'll cycle through
    // those first, generating aliases into the AliasContext in addition to writing SQL FROM-clause information
View Full Code Here

    if ( ScalarReturn.class.isInstance( rootReturn ) ) {
      printWriter.println( extractDetails( (ScalarReturn) rootReturn ) );
    }
    else if ( EntityReturn.class.isInstance( rootReturn ) ) {
      final EntityReturn entityReturn = (EntityReturn) rootReturn;
      printWriter.println( extractDetails( entityReturn ) );
      writeEntityReferenceFetches( entityReturn, depth+1, printWriter );
    }
    else if ( CollectionReference.class.isInstance( rootReturn ) ) {
      final CollectionReference collectionReference = (CollectionReference) rootReturn;
View Full Code 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,
              readerCollector,
View Full Code Here

  public EntityReference resolveEntityReference() {
    return resolveFetchSourceEntityReference( this );
  }

  private static EntityReference resolveFetchSourceEntityReference(CompositeFetch fetch) {
    final FetchSource fetchSource = fetch.getSource();

    if ( EntityReference.class.isInstance( fetchSource ) ) {
      return (EntityReference) fetchSource;
    }
    else if ( CompositeFetch.class.isInstance( fetchSource ) ) {
View Full Code Here

      // element join (that's how the joins are built as of now..)
      //
      // todo : remove this assumption ^^; maybe we make CollectionQuerySpace "special" and rather than have it
      // hold a list of joins, we have it expose the 2 (index, element) separately.

      Join collectionElementJoin = null;
      for ( Join collectionJoin : rightHandSide.getJoins() ) {
        collectionElementJoin = collectionJoin;
      }
      if ( collectionElementJoin == null ) {
        throw new IllegalStateException(
            String.format(
                "Could not locate collection element join within collection join [%s : %s]",
                rightHandSide.getUid(),
                rightHandSide.getCollectionPersister()
            )
        );
      }
      aliasResolutionContext.registerQuerySpaceAliases(
          collectionElementJoin.getRightHandSide().getUid(),
          new EntityReferenceAliasesImpl(
              aliases.getElementTableAlias(),
              aliases.getEntityElementColumnAliases()
          )
      );
View Full Code Here

TOP

Related Classes of org.hibernate.loader.plan2.exec.process.internal.EntityReferenceInitializerImpl

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.