Examples of FromClause


Examples of org.hibernate.hql.ast.tree.FromClause

  public SelectClause getSelectClause() {
    return selectClause;
  }
 
  public FromClause getFinalFromClause() {
    FromClause top = currentFromClause;
    while ( top.getParentFromClause() != null ) {
      top = top.getParentFromClause();
    }
    return top;
  }
View Full Code Here

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

  }

  @Override
  protected void prepareVersioned(AST updateNode, AST versioned) throws SemanticException {
    UpdateStatement updateStatement = (UpdateStatement) updateNode;
    FromClause fromClause = updateStatement.getFromClause();
    if ( versioned != null ) {
      // Make sure that the persister is versioned
      Queryable persister = fromClause.getFromElement().getQueryable();
      if ( !persister.isVersioned() ) {
        throw new SemanticException( "increment option specified for update of non-versioned entity" );
      }

      VersionType versionType = persister.getVersionType();
View Full Code Here

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

  }

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

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

   * @param fromNode The new 'FROM' context.
   * @param inputFromNode The from node from the input AST.
   */
  @Override
  protected void pushFromClause(AST fromNode, AST inputFromNode) {
    FromClause newFromClause = (FromClause) fromNode;
    newFromClause.setParentFromClause( currentFromClause );
    currentFromClause = newFromClause;
  }
View Full Code Here

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

  }

  @Override
  protected void beforeSelectClause() throws SemanticException {
    // Turn off includeSubclasses on all FromElements.
    FromClause from = getCurrentFromClause();
    List fromElements = from.getFromElements();
    for ( Iterator iterator = fromElements.iterator(); iterator.hasNext(); ) {
      FromElement fromElement = (FromElement) iterator.next();
      fromElement.setIncludeSubclasses( false );
    }
  }
View Full Code Here

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

  public SelectClause getSelectClause() {
    return selectClause;
  }

  public FromClause getFinalFromClause() {
    FromClause top = currentFromClause;
    while ( top.getParentFromClause() != null ) {
      top = top.getParentFromClause();
    }
    return top;
  }
View Full Code Here

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

      }
    }
  }

  public void processJoins(QueryNode query) {
    final FromClause fromClause = query.getFromClause();

    final List fromElements;
    if ( DotNode.useThetaStyleImplicitJoins ) {
      // for regression testing against output from the old parser...
      // found it easiest to simply reorder the FromElements here into ascending order
      // in terms of injecting them into the resulting sql ast in orders relative to those
      // expected by the old parser; this is definitely another of those "only needed
      // for regression purposes".  The SyntheticAndFactory, then, simply injects them as it
      // encounters them.
      fromElements = new ArrayList();
      ListIterator liter = fromClause.getFromElements().listIterator( fromClause.getFromElements().size() );
      while ( liter.hasPrevious() ) {
        fromElements.add( liter.previous() );
      }
    }
    else {
      fromElements = fromClause.getFromElements();
    }

    // Iterate through the alias,JoinSequence pairs and generate SQL token nodes.
    Iterator iter = fromElements.iterator();
    while ( iter.hasNext() ) {
      final FromElement fromElement = (FromElement) iter.next();
      JoinSequence join = fromElement.getJoinSequence();
      join.setSelector(
          new JoinSequence.Selector() {
            public boolean includeSubclasses(String alias) {
              // The uber-rule here is that we need to include subclass joins if
              // the FromElement is in any way dereferenced by a property from
              // the subclass table; otherwise we end up with column references
              // qualified by a non-existent table reference in the resulting SQL...
              boolean containsTableAlias = fromClause.containsTableAlias( alias );
              if ( fromElement.isDereferencedBySubclassProperty() ) {
                // TODO : or should we return 'containsTableAlias'??
                LOG.tracev(
                    "Forcing inclusion of extra joins [alias={0}, containsTableAlias={1}]",
                    alias,
                    containsTableAlias
                );
                return true;
              }
              boolean shallowQuery = walker.isShallowQuery();
              boolean includeSubclasses = fromElement.isIncludeSubclasses();
              boolean subQuery = fromClause.isSubQuery();
              return includeSubclasses && containsTableAlias && !subQuery && !shallowQuery;
            }
          }
      );
      addJoinNodes( query, join, fromElement );
View Full Code Here

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

  public LiteralProcessor(HqlSqlWalker hqlSqlWalker) {
    this.walker = hqlSqlWalker;
  }

  public boolean isAlias(String alias) {
    FromClause from = walker.getCurrentFromClause();
    while ( from.isSubQuery() ) {
      if ( from.containsClassAlias( alias ) ) {
        return true;
      }
      from = from.getParentFromClause();
    }
    return from.containsClassAlias( alias );
  }
View Full Code Here

Examples of org.teiid.query.sql.lang.FromClause

               
                // Get last two clauses added to the FROM and combine them into a JoinPredicate
                From from = query.getFrom();
                List clauses = from.getClauses();
                int lastClause = clauses.size()-1;
                FromClause clause1 = (FromClause) clauses.get(lastClause-1);
                FromClause clause2 = (FromClause) clauses.get(lastClause);
                
                //correct the criteria or the join type if necessary
                if (joinType != JoinType.JOIN_CROSS && crits.isEmpty()) {
                    crits.add(QueryRewriter.TRUE_CRITERIA);
                } else if (joinType == JoinType.JOIN_CROSS && !crits.isEmpty()) {
View Full Code Here

Examples of org.teiid.query.sql.lang.FromClause

    * @return Same query with simplified from clause if possible
    */
    private void simplifyFromClause(Query query) {
        From from = query.getFrom();
        List clauses = from.getClauses();
        FromClause rootClause = (FromClause) clauses.get(0);
      
        // If all joins are inner joins, move criteria to WHERE and make
        // FROM a list of groups instead of a tree of JoinPredicates
        if(! hasOuterJoins(rootClause)) {
            from.setClauses(new ArrayList());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.