Package org.hibernate.persister.entity

Examples of org.hibernate.persister.entity.Joinable


      return joinSequence;
    }

    // Class names in the FROM clause result in a JoinSequence (the old FromParser does this).
    if ( persister instanceof Joinable ) {
      Joinable joinable = ( Joinable ) persister;
      return fromElement.getSessionFactoryHelper().createJoinSequence().setRoot( joinable, getTableAlias() );
    }
    else {
      return null// TODO: Should this really return null?  If not, figure out something better to do here.
    }
View Full Code Here


    }
    element.initializeEntity( fromClause, className, entityPersister, type, classAlias, tableAlias );
  }

  private FromElement createFromElement(EntityPersister entityPersister) {
    Joinable joinable = ( Joinable ) entityPersister;
    String text = joinable.getTableName();
    AST ast = createFromElement( text );
    FromElement element = ( FromElement ) ast;
    return element;
  }
View Full Code Here

    final String path,
    final int currentDepth,
    final int joinType)
  throws MappingException {

    Joinable joinable = type.getAssociatedJoinable( getFactory() );

    String subalias = generateTableAlias(
        associations.size()+1, //before adding to collection!
        path,
        joinable
      );

    OuterJoinableAssociation assoc = new OuterJoinableAssociation(
        type,
        alias,
        aliasedLhsColumns,
        subalias,
        joinType,
        getFactory(),
        enabledFilters
      );
    assoc.validateJoin(path);
    associations.add(assoc);

    int nextDepth = currentDepth+1;
    if ( !joinable.isCollection() ) {
      if (joinable instanceof OuterJoinLoadable) {
        walkEntityTree(
          (OuterJoinLoadable) joinable,
          subalias,
          path,
View Full Code Here

      for ( int i=0; i<associations.size(); i++ ) {
        OuterJoinableAssociation join = (OuterJoinableAssociation) associations.get(i);
        OuterJoinableAssociation next = (i == associations.size() - 1)
                ? null
                : ( OuterJoinableAssociation ) associations.get( i + 1 );
        final Joinable joinable = join.getJoinable();
        final String entitySuffix = ( suffixes == null || entityAliasCount >= suffixes.length )
                ? null
                : suffixes[entityAliasCount];
        final String collectionSuffix = ( collectionSuffixes == null || collectionAliasCount >= collectionSuffixes.length )
                ? null
                : collectionSuffixes[collectionAliasCount];
        final String selectFragment = joinable.selectFragment(
            next == null ? null : next.getJoinable(),
            next == null ? null : next.getRHSAlias(),
            join.getRHSAlias(),
            entitySuffix,
                collectionSuffix,
            join.getJoinType()==JoinFragment.LEFT_OUTER_JOIN
        );
        buf.append(selectFragment);
        if ( joinable.consumesEntityAlias() ) entityAliasCount++;
        if ( joinable.consumesCollectionAlias() && join.getJoinType()==JoinFragment.LEFT_OUTER_JOIN ) collectionAliasCount++;
        if (
          i<associations.size()-1 &&
          selectFragment.trim().length()>0
        ) {
          buf.append(", ");
View Full Code Here

      return joinSequence;
    }

    // Class names in the FROM clause result in a JoinSequence (the old FromParser does this).
    if ( persister instanceof Joinable ) {
      Joinable joinable = ( Joinable ) persister;
      return fromElement.getSessionFactoryHelper().createJoinSequence().setRoot( joinable, getTableAlias() );
    }
    else {
      return null// TODO: Should this really return null?  If not, figure out something better to do here.
    }
View Full Code Here

    }
    element.initializeEntity( fromClause, className, entityPersister, type, classAlias, tableAlias );
  }

  private FromElement createFromElement(EntityPersister entityPersister) {
    Joinable joinable = ( Joinable ) entityPersister;
    String text = joinable.getTableName();
    AST ast = createFromElement( text );
    FromElement element = ( FromElement ) ast;
    return element;
  }
View Full Code Here

        Collections.addAll( spaces, (String[]) persister.getQuerySpaces() );
      }
      for ( CollectionPersister persister : alias2CollectionPersister.values() ) {
        final Type elementType = persister.getElementType();
        if ( elementType.isEntityType() && ! elementType.isAnyType() ) {
          final Joinable joinable = ( (EntityType) elementType ).getAssociatedJoinable( factory );
          Collections.addAll( spaces, (String[]) ( (EntityPersister) joinable ).getQuerySpaces() );
        }
      }
    }
View Full Code Here

        rightHandSideRequired
    );
  }

  private static String[] determineRhsColumnNames(EntityType entityType, SessionFactoryImplementor sessionFactory) {
    final Joinable persister = entityType.getAssociatedJoinable( sessionFactory );
    return entityType.getRHSUniqueKeyPropertyName() == null ?
        persister.getKeyColumnNames() :
        ( (PropertyMapping) persister ).toColumns( entityType.getRHSUniqueKeyPropertyName() );
  }
View Full Code Here

      final String alias,
      final PropertyPath path,
      final int currentDepth,
      final JoinType joinType) throws MappingException {

    Joinable joinable = type.getAssociatedJoinable( getFactory() );

    // important to generate alias based on size of association collection
    // *before* adding this join to that collection
    String subalias = generateTableAlias( associations.size() + 1, path, joinable );

    // NOTE : it should be fine to continue to pass only filters below
    // (instead of LoadQueryInfluencers) since "from that point on" we
    // only need to worry about restrictions (and not say adding more
    // joins)
    OuterJoinableAssociation assoc = new OuterJoinableAssociation(
        path,
        type,
        alias,
        aliasedLhsColumns,
        subalias,
        joinType,
        getWithClause(path),
        hasRestriction( path ),
        getFactory(),
        loadQueryInfluencers.getEnabledFilters()
    );
    assoc.validateJoin( path.getFullPath() );
    associations.add( assoc );

    int nextDepth = currentDepth + 1;
//    path = "";
    if ( !joinable.isCollection() ) {
      if (joinable instanceof OuterJoinLoadable) {
        walkEntityTree(
          (OuterJoinLoadable) joinable,
          subalias,
          path,
View Full Code Here

      for ( int i=0; i<associations.size(); i++ ) {
        OuterJoinableAssociation join = (OuterJoinableAssociation) associations.get(i);
        OuterJoinableAssociation next = (i == associations.size() - 1)
                ? null
                : ( OuterJoinableAssociation ) associations.get( i + 1 );
        final Joinable joinable = join.getJoinable();
        final String entitySuffix = ( suffixes == null || entityAliasCount >= suffixes.length )
                ? null
                : suffixes[entityAliasCount];
        final String collectionSuffix = ( collectionSuffixes == null || collectionAliasCount >= collectionSuffixes.length )
                ? null
                : collectionSuffixes[collectionAliasCount];
        final String selectFragment = joinable.selectFragment(
            next == null ? null : next.getJoinable(),
            next == null ? null : next.getRHSAlias(),
            join.getRHSAlias(),
            entitySuffix,
                collectionSuffix,
            join.getJoinType()==JoinType.LEFT_OUTER_JOIN
        );
        if (selectFragment.trim().length() > 0) {
          buf.append(", ").append(selectFragment);
        }
        if ( joinable.consumesEntityAlias() ) entityAliasCount++;
        if ( joinable.consumesCollectionAlias() && join.getJoinType()==JoinType.LEFT_OUTER_JOIN ) collectionAliasCount++;
      }
      return buf.toString();
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.persister.entity.Joinable

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.