Package org.hibernate.engine

Examples of org.hibernate.engine.JoinSequence$Join


    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

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

  }

  FromElement createCollectionElementsJoin(
          QueryableCollection queryableCollection,
          String collectionName) throws SemanticException {
    JoinSequence collectionJoinSequence = fromClause.getSessionFactoryHelper()
            .createCollectionJoinSequence( queryableCollection, collectionName );
    this.queryableCollection = queryableCollection;
    return createCollectionJoin( collectionJoinSequence, null );
  }
View Full Code Here

    Type elementType = queryableCollection.getElementType();
    if ( elementType.isEntityType() ) {       // A collection of entities...
      elem = createEntityAssociation( role, roleAlias, joinType );
    }
    else if ( elementType.isComponentType() ) {    // A collection of components...
      JoinSequence joinSequence = createJoinSequence( roleAlias, joinType );
      elem = createCollectionJoin( joinSequence, roleAlias );
    }
    else {                      // A collection of scalar elements...
      JoinSequence joinSequence = createJoinSequence( roleAlias, joinType );
      elem = createCollectionJoin( joinSequence, roleAlias );
    }

    elem.setRole( role );
    elem.setQueryableCollection( queryableCollection );
View Full Code Here

    String[] targetColumns = sfh.getCollectionElementColumns( role, roleAlias );
    AssociationType elementAssociationType = sfh.getElementAssociationType( type );

    // Create the join element under the from element.
    int joinType = JoinFragment.INNER_JOIN;
    JoinSequence joinSequence = sfh.createJoinSequence( implied, elementAssociationType, tableAlias, joinType, targetColumns );
    elem = initializeJoin( path, destination, joinSequence, targetColumns, origin, false );
    elem.setUseFromFragment( true )// The associated entity is implied, but it must be included in the FROM.
    elem.setCollectionTableAlias( roleAlias )// The collection alias is the role.
    return elem;
  }
View Full Code Here

    // Get the class name of the associated entity.
    if ( queryableCollection.isOneToMany() ) {
      if ( log.isDebugEnabled() ) {
        log.debug( "createEntityAssociation() : One to many - path = " + path + " role = " + role + " associatedEntityName = " + associatedEntityName );
      }
      JoinSequence joinSequence = createJoinSequence( roleAlias, joinType );

      elem = createJoin( associatedEntityName, roleAlias, joinSequence, ( EntityType ) queryableCollection.getElementType(), false );
    }
    else {
      if ( log.isDebugEnabled() ) {
View Full Code Here

          int joinType) throws SemanticException {
    FromElement elem;
    SessionFactoryHelper sfh = fromClause.getSessionFactoryHelper();
    if ( inElementsFunction /*implied*/ ) {
      // For implied many-to-many, just add the end join.
      JoinSequence joinSequence = createJoinSequence( roleAlias, joinType );
      elem = createJoin( associatedEntityName, roleAlias, joinSequence, type, true );
    }
    else {
      // For an explicit many-to-many relationship, add a second join from the intermediate
      // (many-to-many) table to the destination table.  Also, make sure that the from element's
      // idea of the destination is the destination table.
      String tableAlias = fromClause.getAliasGenerator().createName( entityPersister.getEntityName() );
      String[] secondJoinColumns = sfh.getCollectionElementColumns( role, roleAlias );
      // Add the second join, the one that ends in the destination table.
      JoinSequence joinSequence = createJoinSequence( roleAlias, joinType );
      joinSequence.addJoin( sfh.getElementAssociationType( collectionType ), tableAlias, joinType, secondJoinColumns );
      elem = createJoin( associatedEntityName, tableAlias, joinSequence, type, false );
      elem.setUseFromFragment( true );
    }
    return elem;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.JoinSequence$Join

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.