Package org.hibernate.sql

Examples of org.hibernate.sql.SimpleSelect


  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

  /**
   * 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 generateLockString(int lockTimeout) {
    SessionFactoryImplementor factory = getLockable().getFactory();
    LockOptions lockOptions = new LockOptions( getLockMode() );
    lockOptions.setTimeOut( lockTimeout );
    SimpleSelect select = new SimpleSelect( factory.getDialect() )
        .setLockOptions( lockOptions )
        .setTableName( getLockable().getRootTableName() )
        .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
        .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
    if ( getLockable().isVersioned() ) {
      select.addCondition( getLockable().getVersionColumnName(), "=?" );
    }
    if ( factory.getSettings().isCommentsEnabled() ) {
      select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
    }
    return select.toStatementString();
  }
View Full Code Here

  protected String generateLockString(int lockTimeout) {
    SessionFactoryImplementor factory = getLockable().getFactory();
    LockOptions lockOptions = new LockOptions( getLockMode() );
    lockOptions.setTimeOut( lockTimeout );
    SimpleSelect select = new SimpleSelect( factory.getDialect() )
        .setLockOptions( lockOptions )
        .setTableName( getLockable().getRootTableName() )
        .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
        .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
    if ( getLockable().isVersioned() ) {
      select.addCondition( getLockable().getVersionColumnName(), "=?" );
    }
    if ( factory.getSettings().isCommentsEnabled() ) {
      select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
    }
    return select.toStatementString();
  }
View Full Code Here

  protected String generateLockString(int timeout) {
    SessionFactoryImplementor factory = getLockable().getFactory();
    LockOptions lockOptions = new LockOptions( getLockMode() );
    lockOptions.setTimeOut( timeout );
    SimpleSelect select = new SimpleSelect( factory.getDialect() )
        .setLockOptions( lockOptions )
        .setTableName( getLockable().getRootTableName() )
        .addColumn( getLockable().getRootTableIdentifierColumnNames()[0] )
        .addCondition( getLockable().getRootTableIdentifierColumnNames(), "=?" );
    if ( getLockable().isVersioned() ) {
      select.addCondition( getLockable().getVersionColumnName(), "=?" );
    }
    if ( factory.getSettings().isCommentsEnabled() ) {
      select.setComment( getLockMode() + " lock " + getLockable().getEntityName() );
    }
    return select.toStatementString();
  }
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

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.