Package org.hibernate.sql

Examples of org.hibernate.sql.Delete


  /**
   * Generate the SQL that deletes a row by id (and version)
   */
  protected String generateDeleteString(int j) {
    Delete delete = new Delete()
        .setTableName( getTableName( j ) )
        .addPrimaryKeyColumns( getKeyColumns( j ) );
    if ( j == 0 ) {
      delete.setVersionColumnName( getVersionColumnName() );
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      delete.setComment( "delete " + getEntityName() );
    }
    return delete.toStatementString();
  }
View Full Code Here


  private String[] generateSQLDeletStrings(Object[] loadedState) {
    int span = getTableSpan();
    String[] deleteStrings = new String[span];
    for ( int j = span - 1; j >= 0; j-- ) {
      Delete delete = new Delete()
          .setTableName( getTableName( j ) )
          .addPrimaryKeyColumns( getKeyColumns( j ) );
      if ( getFactory().getSettings().isCommentsEnabled() ) {
        delete.setComment( "delete " + getEntityName() + " [" + j + "]" );
      }

      boolean[] versionability = getPropertyVersionability();
      Type[] types = getPropertyTypes();
      for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
        if ( isPropertyOfTable( i, j ) && versionability[i] ) {
          // this property belongs to the table and it is not specifically
          // excluded from optimistic locking by optimistic-lock="false"
          String[] propertyColumnNames = getPropertyColumnNames( i );
          boolean[] propertyNullness = types[i].toColumnNullness( loadedState[i], getFactory() );
          for ( int k = 0; k < propertyNullness.length; k++ ) {
            if ( propertyNullness[k] ) {
              delete.addWhereFragment( propertyColumnNames[k] + " = ?" );
            }
            else {
              delete.addWhereFragment( propertyColumnNames[k] + " is null" );
            }
          }
        }
      }
      deleteStrings[j] = delete.toStatementString();
    }
    return deleteStrings;
  }
View Full Code Here

   * Generate the SQL DELETE that deletes all rows
   */
  @Override
    protected String generateDeleteString() {
   
    Delete delete = new Delete()
        .setTableName( qualifiedTableName )
        .addPrimaryKeyColumns( keyColumnNames );
   
    if ( hasWhere ) delete.setWhere( sqlWhereString );
   
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      delete.setComment( "delete collection " + getRole() );
    }
   
    return delete.toStatementString();
  }
View Full Code Here

   * Generate the SQL DELETE that deletes a particular row
   */
  @Override
    protected String generateDeleteRowString() {
   
    Delete delete = new Delete()
      .setTableName( qualifiedTableName );
   
    if ( hasIdentifier ) {
      delete.addPrimaryKeyColumns( new String[]{ identifierColumnName } );
    }
    else if ( hasIndex && !indexContainsFormula ) {
      delete.addPrimaryKeyColumns( ArrayHelper.join( keyColumnNames, indexColumnNames ) );
    }
    else {
      delete.addPrimaryKeyColumns( keyColumnNames );
      delete.addPrimaryKeyColumns( elementColumnNames, elementColumnIsInPrimaryKey, elementColumnWriters );
    }
   
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      delete.setComment( "delete collection row " + getRole() );
    }
   
    return delete.toStatementString();
  }
View Full Code Here

  /**
   * Generate the SQL that deletes a row by id (and version)
   */
  protected String generateDeleteString(int j) {
    Delete delete = new Delete()
        .setTableName( getTableName( j ) )
        .addPrimaryKeyColumns( getKeyColumns( j ) );
    if ( j == 0 ) {
      delete.setVersionColumnName( getVersionColumnName() );
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      delete.setComment( "delete " + getEntityName() );
    }
    return delete.toStatementString();
  }
View Full Code Here

  private String[] generateSQLDeletStrings(Object[] loadedState) {
    int span = getTableSpan();
    String[] deleteStrings = new String[span];
    for ( int j = span - 1; j >= 0; j-- ) {
      Delete delete = new Delete()
          .setTableName( getTableName( j ) )
          .addPrimaryKeyColumns( getKeyColumns( j ) );
      if ( getFactory().getSettings().isCommentsEnabled() ) {
        delete.setComment( "delete " + getEntityName() + " [" + j + "]" );
      }

      boolean[] versionability = getPropertyVersionability();
      Type[] types = getPropertyTypes();
      for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
        if ( isPropertyOfTable( i, j ) && versionability[i] ) {
          // this property belongs to the table and it is not specifically
          // excluded from optimistic locking by optimistic-lock="false"
          String[] propertyColumnNames = getPropertyColumnNames( i );
          boolean[] propertyNullness = types[i].toColumnNullness( loadedState[i], getFactory() );
          for ( int k = 0; k < propertyNullness.length; k++ ) {
            if ( propertyNullness[k] ) {
              delete.addWhereFragment( propertyColumnNames[k] + " = ?" );
            }
            else {
              delete.addWhereFragment( propertyColumnNames[k] + " is null" );
            }
          }
        }
      }
      deleteStrings[j] = delete.toStatementString();
    }
    return deleteStrings;
  }
View Full Code Here

  /**
   * Generate the SQL that deletes a row by id (and version)
   */
  protected String generateDeleteString(int j) {
    Delete delete = new Delete()
        .setTableName( getTableName( j ) )
        .addPrimaryKeyColumns( getKeyColumns( j ) );
    if ( j == 0 ) {
      delete.setVersionColumnName( getVersionColumnName() );
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      delete.setComment( "delete " + getEntityName() );
    }
    return delete.toStatementString();
  }
View Full Code Here

  private String[] generateSQLDeletStrings(Object[] loadedState) {
    int span = getTableSpan();
    String[] deleteStrings = new String[span];
    for ( int j = span - 1; j >= 0; j-- ) {
      Delete delete = new Delete()
          .setTableName( getTableName( j ) )
          .addPrimaryKeyColumns( getKeyColumns( j ) );
      if ( getFactory().getSettings().isCommentsEnabled() ) {
        delete.setComment( "delete " + getEntityName() + " [" + j + "]" );
      }

      boolean[] versionability = getPropertyVersionability();
      Type[] types = getPropertyTypes();
      for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
        if ( isPropertyOfTable( i, j ) && versionability[i] ) {
          // this property belongs to the table and it is not specifically
          // excluded from optimistic locking by optimistic-lock="false"
          String[] propertyColumnNames = getPropertyColumnNames( i );
          boolean[] propertyNullness = types[i].toColumnNullness( loadedState[i], getFactory() );
          for ( int k = 0; k < propertyNullness.length; k++ ) {
            if ( propertyNullness[k] ) {
              delete.addWhereFragment( propertyColumnNames[k] + " = ?" );
            }
            else {
              delete.addWhereFragment( propertyColumnNames[k] + " is null" );
            }
          }
        }
      }
      deleteStrings[j] = delete.toStatementString();
    }
    return deleteStrings;
  }
View Full Code Here

  /**
   * Generate the SQL that deletes a row by id (and version)
   */
  protected String generateDeleteString(int j) {
    Delete delete = new Delete()
        .setTableName( getTableName( j ) )
        .addPrimaryKeyColumns( getKeyColumns( j ) );
    if ( j == 0 ) {
      delete.setVersionColumnName( getVersionColumnName() );
    }
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      delete.setComment( "delete " + getEntityName() );
    }
    return delete.toStatementString();
  }
View Full Code Here

  private String[] generateSQLDeletStrings(Object[] loadedState) {
    int span = getTableSpan();
    String[] deleteStrings = new String[span];
    for ( int j = span - 1; j >= 0; j-- ) {
      Delete delete = new Delete()
          .setTableName( getTableName( j ) )
          .addPrimaryKeyColumns( getKeyColumns( j ) );
      if ( getFactory().getSettings().isCommentsEnabled() ) {
        delete.setComment( "delete " + getEntityName() + " [" + j + "]" );
      }

      boolean[] versionability = getPropertyVersionability();
      Type[] types = getPropertyTypes();
      for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
        if ( isPropertyOfTable( i, j ) && versionability[i] ) {
          // this property belongs to the table and it is not specifically
          // excluded from optimistic locking by optimistic-lock="false"
          String[] propertyColumnNames = getPropertyColumnNames( i );
          boolean[] propertyNullness = types[i].toColumnNullness( loadedState[i], getFactory() );
          for ( int k = 0; k < propertyNullness.length; k++ ) {
            if ( propertyNullness[k] ) {
              delete.addWhereFragment( propertyColumnNames[k] + " = ?" );
            }
            else {
              delete.addWhereFragment( propertyColumnNames[k] + " is null" );
            }
          }
        }
      }
      deleteStrings[j] = delete.toStatementString();
    }
    return deleteStrings;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.sql.Delete

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.