Package org.hibernate.persister.walking.spi

Examples of org.hibernate.persister.walking.spi.WalkingException


    @Override
    public CollectionFetch buildCollectionFetch(
        AssociationAttributeDefinition attributeDefinition,
        FetchStrategy fetchStrategy,
        LoadPlanBuildingContext loadPlanBuildingContext) {
      throw new WalkingException( "Entity identifier cannot contain persistent collections" );
    }
View Full Code Here


      return ( (FetchOwner) entityReference ).retrieveFetchSourcePersister();
    }

    @Override
    public void injectIdentifierDescription(IdentifierDescription identifierDescription) {
      throw new WalkingException(
          "IdentifierDescription collector should not get injected with IdentifierDescription"
      );
    }
View Full Code Here

        final boolean isCompositeType = entityReference.getEntityPersister().getIdentifierType().isComponentType();

        @Override
        protected FetchMetadata buildFetchMetadata(Fetch fetch) {
          if ( !isCompositeType ) {
            throw new WalkingException( "Non-composite identifier cannot be a fetch owner" );
          }

          if ( !fetch.getOwnerPropertyName().equals( entityReference.getEntityPersister().getIdentifierPropertyName() ) ) {
            throw new IllegalArgumentException(
                String.format(
                    "Fetch owner property name [%s] is not the same as the identifier prop" +
                        fetch.getOwnerPropertyName(),
                    entityReference.getEntityPersister().getIdentifierPropertyName()
                )
            );
          }

          return new FetchMetadata() {
            @Override
            public boolean isNullable() {
              return false;
            }

            @Override
            public Type getType() {
              return entityReference.getEntityPersister().getIdentifierType();
            }

            @Override
            public String[] toSqlSelectFragments(String alias) {
              // should not ever be called iiuc...
              throw new WalkingException( "Should not be called" );
            }
          };
        }
      };
    }
View Full Code Here


        @Override
        protected FetchMetadata buildFetchMetadata(Fetch fetch) {
          if ( !isCompositeType ) {
            throw new WalkingException( "Non-composite identifier cannot be a fetch owner" );
          }

          final int subPropertyIndex = locateSubPropertyIndex( idType, fetch.getOwnerPropertyName() );

          return new FetchMetadata() {
            final Type subType = idType.getSubtypes()[ subPropertyIndex ];

            @Override
            public boolean isNullable() {
              return false;
            }

            @Override
            public Type getType() {
              return subType;
            }

            @Override
            public String[] toSqlSelectFragments(String alias) {
              // should not ever be called iiuc...
              throw new WalkingException( "Should not be called" );
            }
          };
        }

        private int locateSubPropertyIndex(CompositeType idType, String ownerPropertyName) {
View Full Code Here

  // top-level AssociationVisitationStrategy hooks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  @Override
  public void start() {
    if ( ! fetchSourceStack.isEmpty() ) {
      throw new WalkingException(
          "Fetch owner stack was not empty on start; " +
              "be sure to not use LoadPlanBuilderStrategy instances concurrently"
      );
    }
    propertyPathStack.push( new PropertyPath() );
View Full Code Here

  }

  private void checkPoppedEntity(ExpandingFetchSource fetchSource, EntityDefinition entityDefinition) {
    // make sure what we just fetchSource represents entityDefinition
    if ( ! EntityReference.class.isInstance( fetchSource ) ) {
      throw new WalkingException(
          String.format(
              "Mismatched FetchSource from stack on pop.  Expecting EntityReference(%s), but found %s",
              entityDefinition.getEntityPersister().getEntityName(),
              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

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

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

  public void finish() {
    super.finish();
    graphStack.removeLast();
    //applying a little internal stack checking
    if ( !graphStack.isEmpty() || !attributeStack.isEmpty() || !attributeNodeImplementorMap.isEmpty() ) {
      throw new WalkingException( "Internal stack error" );
    }
  }
View Full Code Here

  }

  private void checkedPoppedCollection(CollectionReference poppedCollectionReference, CollectionDefinition collectionDefinition) {
    // make sure what we just poppedCollectionReference represents collectionDefinition.
    if ( ! poppedCollectionReference.getCollectionPersister().equals( collectionDefinition.getCollectionPersister() ) ) {
      throw new WalkingException( "Mismatched CollectionReference from stack on pop" );
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.persister.walking.spi.WalkingException

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.