Package org.hibernate.hql.ast.tree

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


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

    }

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

  public Set getQuerySpaces() {
    return querySpaces;
  }

  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

    fromElement.setAllPropertyFetch(propertyFetch!=null);
    return fromElement;
  }

  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(),
          JoinFragment.INNER_JOIN,
          persister.getElementColumnNames( fkTableAlias ) );
    }
    join.addCondition( fkTableAlias, keyColumnNames, " = ?" );
    fromElement.setJoinSequence( join );
    fromElement.setFilter( true );
    if ( log.isDebugEnabled() ) {
      log.debug( "createFromFilterElement() : processed filter FROM element." );
    }
    return fromElement;
  }
View Full Code Here

    dot.setJoinType( hibernateJoinType )// Tell the dot node about the join type.
    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() );
    FromElement 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

        log.debug( "handleWithFragment() : " + getASTPrinter().showAsString( hqlSqlWithNode, "-- with clause --" ) );
      }
      WithClauseVisitor visitor = new WithClauseVisitor();
      NodeTraverser traverser = new NodeTraverser( visitor );
      traverser.traverseDepthFirst( hqlSqlWithNode );
      FromElement referencedFromElement = visitor.getReferencedFromElement();
      if ( referencedFromElement != fromElement ) {
        throw new InvalidWithClauseException( "with-clause expressions did not reference from-clause element to which the with-clause was associated" );
      }
      SqlGenerator sql = new SqlGenerator( getSessionFactoryHelper().getFactory() );
      sql.whereExpr( hqlSqlWithNode.getFirstChild() );
View Full Code Here

    currentFromClause = currentFromClause.getParentFromClause();
  }

  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.trace( "attempting to resolve property [" + identText + "] as a non-qualified ref" );
        return fromElement.getPropertyMapping( identText ).toType( identText ) != null;
      }
      catch( QueryException e ) {
        // Should mean that no such property was found
      }
    }
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.