Package org.hibernate.hql.internal.ast.tree

Examples of org.hibernate.hql.internal.ast.tree.FromElement


      //          2) here we would need to track each comparison individually, along with
      //              the join alias to which it applies and then pass that information
      //              back to the FromElement so it can pass it along to the JoinSequence
      if ( node instanceof DotNode ) {
        DotNode dotNode = (DotNode) node;
        FromElement fromElement = dotNode.getFromElement();
        if ( referencedFromElement != null ) {
          if ( fromElement != referencedFromElement ) {
            throw new HibernateException( "with-clause referenced two different from-clause elements" );
          }
        }
View Full Code Here


    return querySpaces;
  }

  @Override
  protected AST createFromElement(String path, AST alias, AST propertyFetch) throws SemanticException {
    FromElement fromElement = currentFromClause.addFromElement( path, alias );
    fromElement.setAllPropertyFetch( propertyFetch != null );
    return fromElement;
  }
View Full Code Here

    return fromElement;
  }

  @Override
  protected AST createFromFilterElement(AST filterEntity, AST alias) throws SemanticException {
    FromElement fromElement = currentFromClause.addFromElement( filterEntity.getText(), alias );
    FromClause fromClause = fromElement.getFromClause();
    QueryableCollection persister = sessionFactoryHelper.getCollectionPersister( collectionFilterRole );
    // Get the names of the columns used to link between the collection
    // owner and the collection elements.
    String[] keyColumnNames = persister.getKeyColumnNames();
    String fkTableAlias = persister.isOneToMany()
        ? fromElement.getTableAlias()
        : fromClause.getAliasGenerator().createName( collectionFilterRole );
    JoinSequence join = sessionFactoryHelper.createJoinSequence();
    join.setRoot( persister, fkTableAlias );
    if ( !persister.isOneToMany() ) {
      join.addJoin(
          (AssociationType) persister.getElementType(),
          fromElement.getTableAlias(),
          JoinType.INNER_JOIN,
          persister.getElementColumnNames( fkTableAlias )
      );
    }
    join.addCondition( fkTableAlias, keyColumnNames, " = ?" );
    fromElement.setJoinSequence( join );
    fromElement.setFilter( true );
    LOG.debug( "createFromFilterElement() : processed filter FROM element." );
    return fromElement;
  }
View Full Code Here

    dot.setFetch( fetch );
    // Generate an explicit join for the root dot node.   The implied joins will be collected and passed up
    // to the root dot node.
    dot.resolve( true, false, alias == null ? null : alias.getText() );

    final FromElement fromElement;
    if ( dot.getDataType() != null && dot.getDataType().isComponentType() ) {
      if ( dot.getDataType().isAnyType() ) {
        throw new SemanticException( "An AnyType attribute cannot be join fetched" );
        // ^^ because the discriminator (aka, the "meta columns") must be known to the SQL in
        //     a non-parameterized way.
      }
      FromElementFactory factory = new FromElementFactory(
          getCurrentFromClause(),
          dot.getLhs().getFromElement(),
          dot.getPropertyPath(),
          alias == null ? null : alias.getText(),
          null,
          false
      );
      fromElement = factory.createComponentJoin( (ComponentType) dot.getDataType() );
    }
    else {
      fromElement = dot.getImpliedJoin();
      fromElement.setAllPropertyFetch( propertyFetch != null );

      if ( with != null ) {
        if ( fetch ) {
          throw new SemanticException( "with-clause not allowed on fetched associations; use filters" );
        }
View Full Code Here

      String withClauseJoinAlias = visitor.getJoinAlias();
      if ( withClauseJoinAlias == null ) {
        withClauseJoinAlias = fromElement.getCollectionTableAlias();
      }
      else {
        FromElement referencedFromElement = visitor.getReferencedFromElement();
        if ( referencedFromElement != fromElement ) {
          LOG.warnf(
              "with-clause expressions do not reference the from-clause element to which the " +
                  "with-clause was associated.  The query may not work as expected [%s]",
              queryTranslatorImpl.getQueryString()
View Full Code Here

  }

  @Override
  protected void lookupAlias(AST aliasRef)
      throws SemanticException {
    FromElement alias = currentFromClause.getFromElement( aliasRef.getText() );
    FromReferenceNode aliasRefNode = (FromReferenceNode) aliasRef;
    aliasRefNode.setFromElement( alias );
  }
View Full Code Here

      return false;
    }

    List fromElements = currentFromClause.getExplicitFromElements();
    if ( fromElements.size() == 1 ) {
      final FromElement fromElement = (FromElement) fromElements.get( 0 );
      try {
        LOG.tracev( "Attempting to resolve property [{0}] as a non-qualified ref", identText );
        return fromElement.getPropertyMapping( identText ).toType( identText ) != null;
      }
      catch (QueryException e) {
        // Should mean that no such property was found
      }
    }
View Full Code Here

    return false;
  }

  @Override
  protected AST lookupNonQualifiedProperty(AST property) throws SemanticException {
    final FromElement fromElement = (FromElement) currentFromClause.getExplicitFromElements().get( 0 );
    AST syntheticDotNode = generateSyntheticDotNodeForNonQualifiedPropertyRef( property, fromElement );
    return lookupProperty( syntheticDotNode, false, getCurrentClauseType() == HqlSqlTokenTypes.SELECT );
  }
View Full Code Here

      joinProcessor.processJoins( qn );

      // Attach any mapping-defined "ORDER BY" fragments
      Iterator itr = qn.getFromClause().getProjectionList().iterator();
      while ( itr.hasNext() ) {
        final FromElement fromElement = (FromElement) itr.next();
//      if ( fromElement.isFetch() && fromElement.isCollectionJoin() ) {
        if ( fromElement.isFetch() && fromElement.getQueryableCollection() != null ) {
          // Does the collection referenced by this FromElement
          // specify an order-by attribute?  If so, attach it to
          // the query's order-by
          if ( fromElement.getQueryableCollection().hasOrdering() ) {
            String orderByFragment = fromElement
                .getQueryableCollection()
                .getSQLOrderByString( fromElement.getCollectionTableAlias() );
            qn.getOrderByClause().addOrderFragment( orderByFragment );
          }
          if ( fromElement.getQueryableCollection().hasManyToManyOrdering() ) {
            String orderByFragment = fromElement.getQueryableCollection()
                .getManyToManyOrderByString( fromElement.getTableAlias() );
            qn.getOrderByClause().addOrderFragment( orderByFragment );
          }
        }
      }
    }
View Full Code Here

  }

  protected void postProcessDML(RestrictableStatement statement) throws SemanticException {
    statement.getFromClause().resolve();

    FromElement fromElement = (FromElement) statement.getFromClause().getFromElements().get( 0 );
    Queryable persister = fromElement.getQueryable();
    // Make #@%$^#^&# sure no alias is applied to the table name
    fromElement.setText( persister.getTableName() );

//    // append any filter fragments; the EMPTY_MAP is used under the assumption that
//    // currently enabled filters should not affect this process
//    if ( persister.getDiscriminatorType() != null ) {
//      new SyntheticAndFactory( getASTFactory() ).addDiscriminatorWhereFragment(
//              statement,
//              persister,
//              java.util.Collections.EMPTY_MAP,
//              fromElement.getTableAlias()
//      );
//    }
    if ( persister.getDiscriminatorType() != null || !queryTranslatorImpl.getEnabledFilters().isEmpty() ) {
      new SyntheticAndFactory( this ).addDiscriminatorWhereFragment(
          statement,
          persister,
          queryTranslatorImpl.getEnabledFilters(),
          fromElement.getTableAlias()
      );
    }

  }
View Full Code Here

TOP

Related Classes of org.hibernate.hql.internal.ast.tree.FromElement

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.