Package org.hibernate.engine.internal

Examples of org.hibernate.engine.internal.JoinSequence


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

  }

  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.
    JoinType joinType = JoinType.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

    if ( queryableCollection.isOneToMany() ) {
            LOG.debugf("createEntityAssociation() : One to many - path = %s role = %s associatedEntityName = %s",
                       path,
                       role,
                       associatedEntityName);
      JoinSequence joinSequence = createJoinSequence( roleAlias, joinType );

      elem = createJoin( associatedEntityName, roleAlias, joinSequence, ( EntityType ) queryableCollection.getElementType(), false );
    }
    else {
            LOG.debugf("createManyToMany() : path = %s role = %s associatedEntityName = %s", path, role, associatedEntityName);
View Full Code Here

          JoinType 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

    // 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...
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, JoinType 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

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.