Package org.hibernate.sql

Examples of org.hibernate.sql.SimpleSelect


  /**
   * Generate the SQL that selects the version number by id
   */
  protected String generateSelectVersionString() {
    SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
        .setTableName( getVersionedTableName() );
    if ( isVersioned() ) {
      select.addColumn( versionColumnName );
    }
    else {
      select.addColumns( rootTableKeyColumnNames );
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get version " + getEntityName() );
    }
    return select.addCondition( rootTableKeyColumnNames, "=?" ).toStatementString();
  }
View Full Code Here


        getIdentifierType().sqlTypes( getFactory() )[0]
    );
  }

  public String getSelectByUniqueKeyString(String propertyName) {
    return new SimpleSelect( getFactory().getDialect() )
      .setTableName( getTableName(0) )
      .addColumns( getKeyColumns(0) )
      .addCondition( getPropertyColumnNames(propertyName), "=?" )
      .toStatementString();
  }
View Full Code Here

  /**
   * Generate the SQL that selects a row by id
   */
  protected String generateSelectString(LockMode lockMode) {
    SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
      .setLockMode(lockMode)
      .setTableName( getTableName() )
      .addColumns( getIdentifierColumnNames() )
      .addColumns(
          getSubclassColumnClosure(),
          getSubclassColumnAliasClosure(),
          getSubclassColumnLazyiness()
      )
      .addColumns(
          getSubclassFormulaClosure(),
          getSubclassFormulaAliasClosure(),
          getSubclassFormulaLazyiness()
      );
    //TODO: include the rowids!!!!
    if ( hasSubclasses() ) {
      if ( isDiscriminatorFormula() ) {
        select.addColumn( getDiscriminatorFormula(), getDiscriminatorAlias() );
      }
      else {
        select.addColumn( getDiscriminatorColumnName(), getDiscriminatorAlias() );
      }
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "load " + getEntityName() );
    }
    return select.addCondition( getIdentifierColumnNames(), "=?" ).toStatementString();
  }
View Full Code Here

  protected String generateSelectSizeString(boolean isIntegerIndexed) {
    String selectValue = isIntegerIndexed ?
      "max(" + getIndexColumnNames()[0] + ") + 1": //lists, arrays
      "count(" + getElementColumnNames()[0] + ")"; //sets, maps, bags
    return new SimpleSelect(dialect)
        .setTableName( getTableName() )
        .addCondition( getKeyColumnNames(), "=?" )
        .addColumn(selectValue)
        .toStatementString();
  }
View Full Code Here

  protected String generateDetectRowByIndexString() {
    if ( !hasIndex() ) {
      return null;
    }
    return new SimpleSelect(dialect)
        .setTableName( getTableName() )
        .addCondition( getKeyColumnNames(), "=?" )
        .addCondition( getIndexColumnNames(), "=?" )
        .addCondition( indexFormulas, "=?" )
        .addColumn("1")
View Full Code Here

  protected String generateSelectRowByIndexString() {
    if ( !hasIndex() ) {
      return null;
    }
    return new SimpleSelect(dialect)
        .setTableName( getTableName() )
        .addCondition( getKeyColumnNames(), "=?" )
        .addCondition( getIndexColumnNames(), "=?" )
        .addCondition( indexFormulas, "=?" )
        .addColumns( getElementColumnNames(), elementColumnAliases )
View Full Code Here

        .addColumns( indexFormulas, indexColumnAliases )
        .toStatementString();
  }

  protected String generateDetectRowByElementString() {
    return new SimpleSelect(dialect)
        .setTableName( getTableName() )
        .addCondition( getKeyColumnNames(), "=?" )
        .addCondition( getElementColumnNames(), "=?" )
        .addCondition( elementFormulas, "=?" )
        .addColumn("1")
View Full Code Here

  /**
   * Generate the SQL that selects the version number by id
   */
  protected String generateSelectVersionString() {
    SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
        .setTableName( getVersionedTableName() );
    if ( isVersioned() ) {
      select.addColumn( versionColumnName );
    }
    else {
      select.addColumns( rootTableKeyColumnNames );
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      select.setComment( "get version " + getEntityName() );
    }
    return select.addCondition( rootTableKeyColumnNames, "=?" ).toStatementString();
  }
View Full Code Here

        getIdentifierType().sqlTypes( getFactory() )[0]
    );
  }

  public String getSelectByUniqueKeyString(String propertyName) {
    return new SimpleSelect( getFactory().getDialect() )
      .setTableName( getTableName(0) )
      .addColumns( getKeyColumns(0) )
      .addCondition( getPropertyColumnNames(propertyName), "=?" )
      .toStatementString();
  }
View Full Code Here

  protected String generateSelectSizeString(boolean isIntegerIndexed) {
    String selectValue = isIntegerIndexed ?
      "max(" + getIndexColumnNames()[0] + ") + 1": //lists, arrays
      "count(" + getElementColumnNames()[0] + ")"; //sets, maps, bags
    return new SimpleSelect(dialect)
        .setTableName( getTableName() )
        .addCondition( getKeyColumnNames(), "=?" )
        .addColumn(selectValue)
        .toStatementString();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.sql.SimpleSelect

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.