Package org.hibernate.engine

Examples of org.hibernate.engine.JoinSequence


    addJoin( name, joinSequence );
  }

  void addFromClass(String name, Queryable classPersister)
      throws QueryException {
    JoinSequence joinSequence = new JoinSequence( getFactory() )
        .setRoot( classPersister, name );
    //crossJoins.add(name);
    addFrom( name, classPersister.getEntityName(), joinSequence );
  }
View Full Code Here


    Iterator iter = joins.entrySet().iterator();
    while ( iter.hasNext() ) {
      Map.Entry me = ( Map.Entry ) iter.next();
      String name = ( String ) me.getKey();
      JoinSequence join = ( JoinSequence ) me.getValue();
      join.setSelector( new JoinSequence.Selector() {
        public boolean includeSubclasses(String alias) {
          boolean include = returnedTypes.contains( alias ) && !isShallowQuery();
          return include;
        }
      } );

      if ( typeMap.containsKey( name ) ) {
        ojf.addFragment( join.toJoinFragment( enabledFilters, true ) );
      }
      else if ( collections.containsKey( name ) ) {
        ojf.addFragment( join.toJoinFragment( enabledFilters, true ) );
      }
      else {
        //name from a super query (a bit inelegant that it shows up here)
      }
View Full Code Here

    String[] keyColumnNames = persister.getKeyColumnNames();
    //if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole);

    String collectionName;
    JoinSequence join = new JoinSequence( getFactory() );
    collectionName = persister.isOneToMany() ?
        elementName :
        createNameForCollection( collectionRole );
    join.setRoot( persister, collectionName );
    if ( !persister.isOneToMany() ) {
      //many-to-many
      addCollection( collectionName, collectionRole );
      try {
        join.addJoin( ( AssociationType ) persister.getElementType(),
            elementName,
            JoinFragment.INNER_JOIN,
            persister.getElementColumnNames(collectionName) );
      }
      catch ( MappingException me ) {
        throw new QueryException( me );
      }
    }
    join.addCondition( collectionName, keyColumnNames, " = ?" );
    //if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(collectionName) );
    EntityType elemType = ( EntityType ) collectionElementType;
    addFrom( elementName, elemType.getAssociatedEntityName(), join );

  }
View Full Code Here

      collectionTableAlias = elem.getCollectionTableAlias();
    }

    // TODO: get SQL rendering out of here, create an AST for the join expressions.
    // Use the SQL generator grammar to generate the SQL text for the index expression.
    JoinSequence joinSequence = fromElement.getJoinSequence();
    String[] indexCols = queryableCollection.getIndexColumnNames();
    if ( indexCols.length != 1 ) {
      throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
    }
    SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
    try {
      gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
    }
    catch ( RecognitionException e ) {
      throw new QueryException( e.getMessage(), e );
    }
    String selectorExpression = gen.getSQL();
    joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
    List paramSpecs = gen.getCollectedParameters();
    if ( paramSpecs != null ) {
      switch ( paramSpecs.size() ) {
        case 0 :
          // nothing to do
View Full Code Here

      collectionTableAlias = elem.getCollectionTableAlias();
    }

    // TODO: get SQL rendering out of here, create an AST for the join expressions.
    // Use the SQL generator grammar to generate the SQL text for the index expression.
    JoinSequence joinSequence = fromElement.getJoinSequence();
    String[] indexCols = queryableCollection.getIndexColumnNames();
    if ( indexCols.length != 1 ) {
      throw new QueryException( "composite-index appears in []: " + collectionNode.getPath() );
    }
    SqlGenerator gen = new SqlGenerator( getSessionFactoryHelper().getFactory() );
    try {
      gen.simpleExpr( selector ); //TODO: used to be exprNoParens! was this needed?
    }
    catch ( RecognitionException e ) {
      throw new QueryException( e.getMessage(), e );
    }
    String selectorExpression = gen.getSQL();
    joinSequence.addCondition( collectionTableAlias + '.' + indexCols[0] + " = " + selectorExpression );
    List paramSpecs = gen.getCollectedParameters();
    if ( paramSpecs != null ) {
      switch ( paramSpecs.size() ) {
        case 0 :
          // nothing to do
View Full Code Here

    // 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." );
    }
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
View Full Code Here

   * Generate an empty join sequence instance.
   *
   * @return The generate join sequence.
   */
  public JoinSequence createJoinSequence() {
    return new JoinSequence( sfi );
  }
View Full Code Here

   * @param joinType The type of join to render (inner, outer, etc);  see {@link org.hibernate.sql.JoinFragment}
   * @param columns The columns making up the condition of the join.
   * @return The generated join sequence.
   */
  public JoinSequence createJoinSequence(boolean implicit, AssociationType associationType, String tableAlias, int joinType, String[] columns) {
    JoinSequence joinSequence = createJoinSequence();
    joinSequence.setUseThetaStyle( implicit )// Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from)
    joinSequence.addJoin( associationType, tableAlias, joinType, columns );
    return joinSequence;
  }
View Full Code Here

   * @param collPersister The persister for the collection at which the join should be rooted.
   * @param collectionName The alias to use for qualifying column references.
   * @return The generated join sequence.
   */
  public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName) {
    JoinSequence joinSequence = createJoinSequence();
    joinSequence.setRoot( collPersister, collectionName );
    joinSequence.setUseThetaStyle( true );    // TODO: figure out how this should be set.
///////////////////////////////////////////////////////////////////////////////
// This was the reason for failures regarding INDEX_OP and subclass joins on
// theta-join dialects; not sure what behaviour we were trying to emulate ;)
//    joinSequence = joinSequence.getFromPart();  // Emulate the old addFromOnly behavior.
    return joinSequence;
View Full Code Here

TOP

Related Classes of org.hibernate.engine.JoinSequence

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.