Package org.hibernate.engine.internal

Examples of org.hibernate.engine.internal.JoinSequence


   * @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 behavior we were trying to emulate ;)
//    joinSequence = joinSequence.getFromPart();  // Emulate the old addFromOnly behavior.
    return joinSequence;
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

    boolean useFoundFromElement = found && ( elem.isImplied() || areSame( classAlias, elem.getClassAlias() ) );

    if ( ! useFoundFromElement ) {
      // If this is an implied join in a from element, then use the impled join type which is part of the
      // tree parser's state (set by the gramamar actions).
      JoinSequence joinSequence = getSessionFactoryHelper()
        .createJoinSequence( impliedJoin, propertyType, tableAlias, joinType, joinColumns );

      // If the lhs of the join is a "component join", we need to go back to the
      // first non-component-join as the origin to properly link aliases and
      // join columns
View Full Code Here

    if ( alias != null ) {
      reset( q ); //reset the dotcount (but not the path)
      currentName = alias; //after reset!
      currentPropertyMapping = q.getPropertyMapping( currentName );
      if ( !ignoreInitialJoin ) {
        JoinSequence ojf = q.getPathJoin( path.toString() );
        try {
          joinSequence.addCondition( ojf.toJoinFragment( q.getEnabledFilters(), true ).toWhereFragmentString() ); //after reset!
        }
        catch ( MappingException me ) {
          throw new QueryException( me );
        }
        // we don't need to worry about any condition in the ON clause
View Full Code Here

  public void start(QueryTranslatorImpl q) {
    if ( !continuation ) {
      reset( q );
      path.setLength( 0 );
      joinSequence = new JoinSequence( q.getFactory() ).setUseThetaStyle( useThetaStyleJoin );
    }
  }
View Full Code Here

    if ( !collPersister.hasIndex() ) throw new QueryException( "unindexed collection before []: " + path );
    String[] indexCols = collPersister.getIndexColumnNames();
    if ( indexCols.length != 1 ) throw new QueryException( "composite-index appears in []: " + path );
    //String[] keyCols = collPersister.getKeyColumnNames();

    JoinSequence fromJoins = new JoinSequence( q.getFactory() )
        .setUseThetaStyle( useThetaStyleJoin )
        .setRoot( collPersister, collectionName )
        .setNext( joinSequence.copy() );

    if ( !continuation ) addJoin( collectionName, collPersister.getCollectionType() );
View Full Code Here

    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

    boolean useFoundFromElement = found && ( elem.isImplied() || areSame( classAlias, elem.getClassAlias() ) );

    if ( ! useFoundFromElement ) {
      // If this is an implied join in a from element, then use the impled join type which is part of the
      // tree parser's state (set by the gramamar actions).
      JoinSequence joinSequence = getSessionFactoryHelper()
        .createJoinSequence( impliedJoin, propertyType, tableAlias, joinType, joinColumns );

      // If the lhs of the join is a "component join", we need to go back to the
      // first non-component-join as the origin to properly link aliases and
      // join columns
View Full Code Here

TOP

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