Package org.hibernate.persister.walking.spi

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


            if ( type.isAssociationType() ) {
              final AssociationType aType = (AssociationType) type;
              return new AssociationAttributeDefinition() {
                @Override
                public AssociationKey getAssociationKey() {
                  return new AssociationKey( lhsTableName, subAttributeLhsColumns );
                }


                @Override
                public AssociationNature getAssociationNature() {
View Full Code Here


  }

  @Override
  public void foundCircularAssociation(AssociationAttributeDefinition attributeDefinition) {
    // todo : use this information to create the BiDirectionalEntityFetch instances
    final AssociationKey associationKey = attributeDefinition.getAssociationKey();
    final FetchOwner fetchOwner = fetchedAssociationKeyOwnerMap.get( associationKey );
    if ( fetchOwner == null ) {
      throw new IllegalStateException(
          String.format(
              "Expecting AssociationKey->FetchOwner mapping for %s",
              associationKey.toString()
          )
      );
    }

    currentFetchOwner().addFetch( new CircularFetch( currentFetchOwner(), fetchOwner, attributeDefinition ) );
View Full Code Here

            int columnPosition = currentColumnPosition;
            currentColumnPosition += type.getColumnSpan( sessionFactory() );

            if ( type.isAssociationType() ) {
              // we build the association-key here because of the "goofiness" with 'currentColumnPosition'
              final AssociationKey associationKey;
              final AssociationType aType = (AssociationType) type;
              final Joinable joinable = aType.getAssociatedJoinable( sessionFactory() );

              if ( aType.isAnyType() ) {
                associationKey = new AssociationKey(
                    JoinHelper.getLHSTableName(
                        aType,
                        attributeNumber(),
                        (OuterJoinLoadable) locateOwningPersister()
                    ),
                    JoinHelper.getLHSColumnNames(
                        aType,
                        attributeNumber(),
                        columnPosition,
                        (OuterJoinLoadable) locateOwningPersister(),
                        sessionFactory()
                    )
                );
              }
              else if ( aType.getForeignKeyDirection() == ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT ) {
                final String lhsTableName;
                final String[] lhsColumnNames;

                if ( joinable.isCollection() ) {
                  final QueryableCollection collectionPersister = (QueryableCollection) joinable;
                  lhsTableName = collectionPersister.getTableName();
                  lhsColumnNames = collectionPersister.getElementColumnNames();
                }
                else {
                  final OuterJoinLoadable entityPersister = (OuterJoinLoadable) locateOwningPersister();
                  lhsTableName = getLHSTableName( aType, attributeNumber(), entityPersister );
                  lhsColumnNames = getLHSColumnNames(
                      aType,
                      attributeNumber(),
                      columnPosition,
                      entityPersister,
                      sessionFactory()
                  );
                }
                associationKey = new AssociationKey( lhsTableName, lhsColumnNames );
              }
              else {
                associationKey = new AssociationKey(
                    joinable.getTableName(),
                    getRHSColumnNames( aType, sessionFactory() )
                );
              }
View Full Code Here

    pushToStack( entityReturn );

    // also add an AssociationKey for the root so we can later on recognize circular references back to the root.
    final Joinable entityPersister = (Joinable) entityDefinition.getEntityPersister();
    associationKeyRegistered(
        new AssociationKey( entityPersister.getTableName(), entityPersister.getKeyColumnNames() )
    );
  }
View Full Code Here

    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

    final FetchStrategy fetchStrategy = determineFetchStrategy( attributeDefinition );
    if ( fetchStrategy.getStyle() != FetchStyle.JOIN ) {
      return; // nothing to do
    }

    final AssociationKey associationKey = attributeDefinition.getAssociationKey();

    // go ahead and build the bidirectional fetch
    if ( attributeDefinition.getAssociationNature() == AssociationAttributeDefinition.AssociationNature.ENTITY ) {
      final Joinable currentEntityPersister = (Joinable) currentSource().resolveEntityReference().getEntityPersister();
      final AssociationKey currentEntityReferenceAssociationKey =
          new AssociationKey( currentEntityPersister.getTableName(), currentEntityPersister.getKeyColumnNames() );
      // if associationKey is equal to currentEntityReferenceAssociationKey
      // that means that the current EntityPersister has a single primary key attribute
      // (i.e., derived attribute) which is mapped by attributeDefinition.
      // This is not a bidirectional association.
      // TODO: AFAICT, to avoid an overflow, the associated entity must already be loaded into the session, or
View Full Code Here

            int columnPosition = currentColumnPosition;
            currentColumnPosition += type.getColumnSpan( sessionFactory() );

            if ( type.isAssociationType() ) {
              // we build the association-key here because of the "goofiness" with 'currentColumnPosition'
              final AssociationKey associationKey;
              final AssociationType aType = (AssociationType) type;
              final Joinable joinable = aType.getAssociatedJoinable( sessionFactory() );
              if ( aType.getForeignKeyDirection() == ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT ) {
                associationKey = new AssociationKey(
                    getLHSTableName(
                        aType,
                        attributeNumber(),
                        (OuterJoinLoadable) joinable
                    ),
                    getLHSColumnNames(
                        aType,
                        attributeNumber(),
                        columnPosition,
                        (OuterJoinLoadable) joinable,
                        sessionFactory()
                    )
                );
              }
              else {
                associationKey = new AssociationKey(
                    joinable.getTableName(),
                    getRHSColumnNames( aType, sessionFactory() )
                );
              }
View Full Code Here

      else {
        final OuterJoinLoadable entityPersister = (OuterJoinLoadable) source();
        lhsTableName = getLHSTableName( type, attributeNumber(), entityPersister );
        lhsColumnNames = getLHSColumnNames( type, attributeNumber(), entityPersister, sessionFactory() );
      }
      return new AssociationKey( lhsTableName, lhsColumnNames );
    }
    else {
      return new AssociationKey( joinable.getTableName(), getRHSColumnNames( type, sessionFactory() ) );
    }
  }
View Full Code Here

                  /* TODO: is this always correct? */
                  //return new AssociationKey(
                  //    joinable.getTableName(),
                  //    JoinHelper.getRHSColumnNames( aType, getEntityPersister().getFactory() )
                  //);
                  return new AssociationKey(
                      lhsTableName,
                      subAttributeLhsColumns
                  );
                }

View Full Code Here

      else {
        final OuterJoinLoadable entityPersister = (OuterJoinLoadable) source();
        lhsTableName = getLHSTableName( type, attributeNumber(), entityPersister );
        lhsColumnNames = getLHSColumnNames( type, attributeNumber(), entityPersister, sessionFactory() );
      }
      return new AssociationKey( lhsTableName, lhsColumnNames );
    }
    else {
      return new AssociationKey( joinable.getTableName(), getRHSColumnNames( type, sessionFactory() ) );
    }
  }
View Full Code Here

TOP

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

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.