Package org.hibernate.persister.entity

Examples of org.hibernate.persister.entity.Joinable


        )
    );
  }

  protected void applyRootReturnWhereJoinRestrictions(SelectStatementBuilder selectStatementBuilder) {
    final Joinable joinable = (OuterJoinLoadable) getRootEntityReturn().getEntityPersister();
    selectStatementBuilder.appendRestrictions(
        joinable.whereJoinFragment(
            entityReferenceAliases.getTableAlias(),
            true,
            true
        )
    );
View Full Code Here


          rightHandSide.getUid(),
          rightHandSide.getEntityPersister()
      );
    }

    final Joinable joinable = (Joinable) rightHandSide.getEntityPersister();
    addJoins(
        join,
        joinFragment,
        joinable
    );
View Full Code Here

//    }

    fetchStats.processingFetch( fetch );

    // First write out the SQL SELECT fragments
    final Joinable joinable = (Joinable) fetch.getEntityPersister();
    EntityReferenceAliases aliases = aliasResolutionContext.resolveEntityReferenceAliases(
        fetch.getQuerySpaceUid()
    );

    // the null arguments here relate to many-to-many fetches
    selectStatementBuilder.appendSelectClauseFragment(
        joinable.selectFragment(
            null,
            null,
            aliases.getTableAlias(),
            aliases.getColumnAliases().getSuffix(),
            null,
View Full Code Here

    final CollectionReferenceAliases aliases = aliasResolutionContext.resolveCollectionReferenceAliases(
        fetch.getQuerySpaceUid()
    );

    final QueryableCollection queryableCollection = (QueryableCollection) fetch.getCollectionPersister();
    final Joinable joinableCollection = (Joinable) fetch.getCollectionPersister();

    if ( fetch.getCollectionPersister().isManyToMany() ) {
      // todo : better way to access `ownerTableAlias` here.
      //     when processing the Join part of this we are able to look up the "lhs table alias" because we know
      //     the 'lhs' QuerySpace.
      //
      // Good idea to be able resolve a Join by lookup on the rhs and lhs uid?  If so, Fetch

      // for many-to-many we have 3 table aliases.  By way of example, consider a normal m-n: User<->Role
      // where User is the FetchOwner and Role (User.roles) is the Fetch.  We'd have:
      //    1) the owner's table : user
      final String ownerTableAlias = aliasResolutionContext.resolveSqlTableAliasFromQuerySpaceUid( fetchSource.getQuerySpaceUid() );
      //    2) the m-n table : user_role
      final String collectionTableAlias = aliases.getCollectionTableAlias();
      //    3) the element table : role
      final String elementTableAlias = aliases.getElementTableAlias();

      // add select fragments from the collection table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      selectStatementBuilder.appendSelectClauseFragment(
          joinableCollection.selectFragment(
              (Joinable) queryableCollection.getElementPersister(),
              elementTableAlias,
              collectionTableAlias,

              aliases.getEntityElementAliases().getColumnAliases().getSuffix(),
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

    if ( subgraphMap == null ) {
      subgraphMap = new HashMap<Class, Subgraph>();
    }

    final AssociationType attributeType = (AssociationType) Helper.resolveType( sessionFactory(), attribute );
    final Joinable joinable = attributeType.getAssociatedJoinable( sessionFactory() );

    if ( joinable.isCollection() ) {
      final EntityPersister elementEntityPersister = ( (QueryableCollection) joinable ).getElementPersister();
      if ( type == null ) {
        type = elementEntityPersister.getMappedClass();
      }
      else  {
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;
      final JoinSequence joinSequence = fromElement.getSessionFactoryHelper().createJoinSequence().setRoot(
          joinable,
          getTableAlias()
      );
      joinSequence.applyTreatAsDeclarations( treatAsDeclarations );
View Full Code Here

   *
   * @return The columns for the right-hand-side of the join
   */
  public static String[] getRHSColumnNames(AssociationType type, SessionFactoryImplementor factory) {
    final String uniqueKeyPropertyName = type.getRHSUniqueKeyPropertyName();
    final Joinable joinable = type.getAssociatedJoinable( factory );
    if ( uniqueKeyPropertyName == null ) {
      return joinable.getKeyColumnNames();
    }
    else {
      return ( (OuterJoinLoadable) joinable ).getPropertyColumnNames( uniqueKeyPropertyName );
    }
  }
View Full Code Here

      // of that fact.
      joinFragment.setHasFilterCondition( joinFragment.addCondition( filterCondition ) );
      addSubclassJoins( joinFragment, rootAlias, rootJoinable, true, includeAllSubclassJoins, treatAsDeclarations );
    }

    Joinable last = rootJoinable;

    for ( Join join : joins ) {
      // technically the treatAsDeclarations should only apply to rootJoinable or to a single Join,
      // but that is not possible atm given how these JoinSequence and Join objects are built.
      // However, it is generally ok given how the HQL parser builds these JoinSequences (a HQL join
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.