Package org.hibernate.hql.ast.tree

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


      case ALIAS_REF:
        // Notify the FROM element that it is being referenced by the select.
        FromReferenceNode aliasRefNode = ( FromReferenceNode ) node;
        //aliasRefNode.resolve( false, false, aliasRefNode.getText() ); //TODO: is it kosher to do it here?
        aliasRefNode.resolve( false, false ); //TODO: is it kosher to do it here?
        FromElement fromElement = aliasRefNode.getFromElement();
        if ( fromElement != null ) {
          fromElement.setIncludeSubclasses( true );
        }
      default:
        break;
    }
  }
View Full Code Here


  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

    }

    // 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.trace( "forcing inclusion of extra joins [alias=" + alias + ", containsTableAlias=" + containsTableAlias + "]" );
                return true;
              }
              boolean shallowQuery = queryTranslatorImpl.isShallowQuery();
              boolean includeSubclasses = fromElement.isIncludeSubclasses();
              boolean subQuery = fromClause.isSubQuery();
              return includeSubclasses && containsTableAlias && !subQuery && !shallowQuery;
            }
          }
      );
View Full Code Here

      //              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

    // Make sure that there is only a single root entity in the return (no tuples)
    if ( getReturnTypes().length > 1 ) {
      throw new HibernateException( "cannot scroll with collection fetches and returned tuples" );
    }

    FromElement owner = null;
    Iterator itr = query.getSelectClause().getFromElementsForLoad().iterator();
    while ( itr.hasNext() ) {
      // should be the first, but just to be safe...
      final FromElement fromElement = ( FromElement ) itr.next();
      if ( fromElement.getOrigin() == null ) {
        owner = fromElement;
        break;
      }
    }
View Full Code Here

  }

  private StatementExecutor buildAppropriateStatementExecutor(HqlSqlWalker walker) {
    Statement statement = ( Statement ) walker.getAST();
    if ( walker.getStatementType() == HqlSqlTokenTypes.DELETE ) {
      FromElement fromElement = walker.getFinalFromClause().getFromElement();
      Queryable persister = fromElement.getQueryable();
      if ( persister.isMultiTable() ) {
        return new MultiTableDeleteExecutor( walker );
      }
      else {
        return new BasicExecutor( walker, persister );
      }
    }
    else if ( walker.getStatementType() == HqlSqlTokenTypes.UPDATE ) {
      FromElement fromElement = walker.getFinalFromClause().getFromElement();
      Queryable persister = fromElement.getQueryable();
      if ( persister.isMultiTable() ) {
        // even here, if only properties mapped to the "base table" are referenced
        // in the set and where clauses, this could be handled by the BasicDelegate.
        // TODO : decide if it is better performance-wise to perform that check, or to simply use the MultiTableUpdateDelegate
        return new MultiTableUpdateExecutor( walker );
View Full Code Here

    if ( !walker.getSessionFactoryHelper().getFactory().getDialect().supportsTemporaryTables() ) {
      throw new HibernateException( "cannot perform multi-table deletes using dialect not supporting temp tables" );
    }

    DeleteStatement deleteStatement = ( DeleteStatement ) walker.getAST();
    FromElement fromElement = deleteStatement.getFromClause().getFromElement();
    String bulkTargetAlias = fromElement.getTableAlias();
    this.persister = fromElement.getQueryable();

    this.idInsertSelect = generateIdInsertSelect( persister, bulkTargetAlias, deleteStatement.getWhereClause() );
    log.trace( "Generated ID-INSERT-SELECT SQL (multi-table delete) : " +  idInsertSelect );

    String[] tableNames = persister.getConstraintOrderedTableNameClosure();
View Full Code Here

    if ( !walker.getSessionFactoryHelper().getFactory().getDialect().supportsTemporaryTables() ) {
      throw new HibernateException( "cannot perform multi-table updates using dialect not supporting temp tables" );
    }

    UpdateStatement updateStatement = ( UpdateStatement ) walker.getAST();
    FromElement fromElement = updateStatement.getFromClause().getFromElement();
    String bulkTargetAlias = fromElement.getTableAlias();
    this.persister = fromElement.getQueryable();

    this.idInsertSelect = generateIdInsertSelect( persister, bulkTargetAlias, updateStatement.getWhereClause() );
    log.trace( "Generated ID-INSERT-SELECT SQL (multi-table update) : " +  idInsertSelect );

    String[] tableNames = persister.getConstraintOrderedTableNameClosure();
View Full Code Here

      //          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

      //          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

TOP

Related Classes of org.hibernate.hql.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.