Package org.hibernate.sql

Examples of org.hibernate.sql.SelectFragment


        new Alias( suffix ).toAliasString( getDiscriminatorAlias() ) :
        null;
  }

  public String identifierSelectFragment(String name, String suffix) {
    return new SelectFragment()
        .setSuffix( suffix )
        .addColumns( name, getIdentifierColumnNames(), getIdentifierAliases() )
        .toFragmentString()
        .substring( 2 ); //strip leading ", "
  }
View Full Code Here


  }


  public String propertySelectFragment(String name, String suffix, boolean allProperties) {

    SelectFragment select = new SelectFragment()
        .setSuffix( suffix )
        .setUsedAliases( getIdentifierAliases() );

    int[] columnTableNumbers = getSubclassColumnTableNumberClosure();
    String[] columnAliases = getSubclassColumnAliasClosure();
    String[] columns = getSubclassColumnClosure();
    for ( int i = 0; i < getSubclassColumnClosure().length; i++ ) {
      boolean selectable = ( allProperties || !subclassColumnLazyClosure[i] ) &&
        !isSubclassTableSequentialSelect( columnTableNumbers[i] ) &&
        subclassColumnSelectableClosure[i];
      if ( selectable ) {
        String subalias = generateTableAlias( name, columnTableNumbers[i] );
        select.addColumn( subalias, columns[i], columnAliases[i] );
      }
    }

    int[] formulaTableNumbers = getSubclassFormulaTableNumberClosure();
    String[] formulaTemplates = getSubclassFormulaTemplateClosure();
    String[] formulaAliases = getSubclassFormulaAliasClosure();
    for ( int i = 0; i < getSubclassFormulaTemplateClosure().length; i++ ) {
      boolean selectable = ( allProperties || !subclassFormulaLazyClosure[i] )
        && !isSubclassTableSequentialSelect( formulaTableNumbers[i] );
      if ( selectable ) {
        String subalias = generateTableAlias( name, formulaTableNumbers[i] );
        select.addFormula( subalias, formulaTemplates[i], formulaAliases[i] );
      }
    }

    if ( entityMetamodel.hasSubclasses() ) {
      addDiscriminatorToSelect( select, name, suffix );
    }

    if ( hasRowId() ) {
      select.addColumn( name, rowIdName, ROWID_ALIAS );
    }

    return select.toFragmentString();
  }
View Full Code Here

  }

  protected String concretePropertySelectFragment(String alias, InclusionChecker inclusionChecker) {
    int propertyCount = getPropertyNames().length;
    int[] propertyTableNumbers = getPropertyTableNumbersInSelect();
    SelectFragment frag = new SelectFragment();
    for ( int i = 0; i < propertyCount; i++ ) {
      if ( inclusionChecker.includeProperty( i ) ) {
        frag.addColumns(
            generateTableAlias( alias, propertyTableNumbers[i] ),
            propertyColumnNames[i],
            propertyColumnAliases[i]
        );
        frag.addFormulas(
            generateTableAlias( alias, propertyTableNumbers[i] ),
            propertyColumnFormulaTemplates[i],
            propertyColumnAliases[i]
        );
      }
    }
    return frag.toFragmentString();
  }
View Full Code Here

  }

  protected SelectFragment createSelect(final int[] subclassColumnNumbers,
                      final int[] subclassFormulaNumbers) {

    SelectFragment selectFragment = new SelectFragment();

    int[] columnTableNumbers = getSubclassColumnTableNumberClosure();
    String[] columnAliases = getSubclassColumnAliasClosure();
    String[] columns = getSubclassColumnClosure();
    for ( int i = 0; i < subclassColumnNumbers.length; i++ ) {
      if ( subclassColumnSelectableClosure[i] ) {
        int columnNumber = subclassColumnNumbers[i];
        final String subalias = generateTableAlias( getRootAlias(), columnTableNumbers[columnNumber] );
        selectFragment.addColumn( subalias, columns[columnNumber], columnAliases[columnNumber] );
      }
    }

    int[] formulaTableNumbers = getSubclassFormulaTableNumberClosure();
    String[] formulaTemplates = getSubclassFormulaTemplateClosure();
    String[] formulaAliases = getSubclassFormulaAliasClosure();
    for ( int i = 0; i < subclassFormulaNumbers.length; i++ ) {
      int formulaNumber = subclassFormulaNumbers[i];
      final String subalias = generateTableAlias( getRootAlias(), formulaTableNumbers[formulaNumber] );
      selectFragment.addFormula( subalias, formulaTemplates[formulaNumber], formulaAliases[formulaNumber] );
    }

    return selectFragment;
  }
View Full Code Here

    //now render the joins
    JoinFragment jf = createJoin( tableNumbers, drivingAlias );

    //now render the select clause
    SelectFragment selectFragment = createSelect( columnNumbers, formulaNumbers );

    //now tie it all together
    Select select = new Select( getFactory().getDialect() );
    select.setSelectClause( selectFragment.toFragmentString().substring( 2 ) );
    select.setFromClause( from );
    select.setWhereClause( where );
    select.setOuterJoins( jf.toFromFragmentString(), jf.toWhereFragmentString() );
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "sequential select " + getEntityName() );
View Full Code Here

  /**
   * Generate a list of collection index, key and element columns
   */
  public String selectFragment(String alias, String columnSuffix) {
    SelectFragment frag = generateSelectFragment( alias, columnSuffix );
    appendElementColumns( frag, alias );
    appendIndexColumns( frag, alias );
    appendIdentifierColumns( frag, alias );

    return frag.toFragmentString()
        .substring( 2 ); //strip leading ','
  }
View Full Code Here

        .addColumn("1")
        .toStatementString();
  }

  protected SelectFragment generateSelectFragment(String alias, String columnSuffix) {
    return new SelectFragment()
        .setSuffix( columnSuffix )
        .addColumns( alias, keyColumnNames, keyColumnAliases );
  }
View Full Code Here

  private String manyToManySelectFragment(
          Joinable rhs,
          String rhsAlias,
          String lhsAlias,
          String collectionSuffix) {
    SelectFragment frag = generateSelectFragment( lhsAlias, collectionSuffix );

    String[] elementColumnNames = rhs.getKeyColumnNames();
    frag.addColumns( rhsAlias, elementColumnNames, elementColumnAliases );
    appendIndexColumns( frag, lhsAlias );
    appendIdentifierColumns( frag, lhsAlias );

    return frag.toFragmentString()
        .substring( 2 ); //strip leading ','
  }
View Full Code Here

        new Alias( suffix ).toAliasString( getDiscriminatorAlias() ) :
        null;
  }

  public String identifierSelectFragment(String name, String suffix) {
    return new SelectFragment()
        .setSuffix( suffix )
        .addColumns( name, getIdentifierColumnNames(), getIdentifierAliases() )
        .toFragmentString()
        .substring( 2 ); //strip leading ", "
  }
View Full Code Here

  }


  public String propertySelectFragment(String name, String suffix, boolean allProperties) {

    SelectFragment select = new SelectFragment()
        .setSuffix( suffix )
        .setUsedAliases( getIdentifierAliases() );

    int[] columnTableNumbers = getSubclassColumnTableNumberClosure();
    String[] columnAliases = getSubclassColumnAliasClosure();
    String[] columns = getSubclassColumnClosure();
    for ( int i = 0; i < getSubclassColumnClosure().length; i++ ) {
      boolean selectable = ( allProperties || !subclassColumnLazyClosure[i] ) &&
        !isSubclassTableSequentialSelect( columnTableNumbers[i] ) &&
        subclassColumnSelectableClosure[i];
      if ( selectable ) {
        String subalias = generateTableAlias( name, columnTableNumbers[i] );
        select.addColumn( subalias, columns[i], columnAliases[i] );
      }
    }

    int[] formulaTableNumbers = getSubclassFormulaTableNumberClosure();
    String[] formulaTemplates = getSubclassFormulaTemplateClosure();
    String[] formulaAliases = getSubclassFormulaAliasClosure();
    for ( int i = 0; i < getSubclassFormulaTemplateClosure().length; i++ ) {
      boolean selectable = ( allProperties || !subclassFormulaLazyClosure[i] )
        && !isSubclassTableSequentialSelect( formulaTableNumbers[i] );
      if ( selectable ) {
        String subalias = generateTableAlias( name, formulaTableNumbers[i] );
        select.addFormula( subalias, formulaTemplates[i], formulaAliases[i] );
      }
    }

    if ( entityMetamodel.hasSubclasses() ) {
      addDiscriminatorToSelect( select, name, suffix );
    }

    if ( hasRowId() ) {
      select.addColumn( name, rowIdName, ROWID_ALIAS );
    }

    return select.toFragmentString();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.sql.SelectFragment

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.