Package org.hibernate.sql

Examples of org.hibernate.sql.Insert


   * Generate the SQL INSERT that creates a new row
   */
  @Override
    protected String generateInsertRowString() {
   
    Insert insert = new Insert( getDialect() )
        .setTableName( qualifiedTableName )
        .addColumns( keyColumnNames );
   
    if ( hasIdentifier) insert.addColumn( identifierColumnName );
   
    if ( hasIndex /*&& !indexIsFormula*/ ) {
      insert.addColumns( indexColumnNames, indexColumnIsSettable );
    }
   
    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert collection row " + getRole() );
    }
   
    //if ( !elementIsFormula ) {
      insert.addColumns( elementColumnNames, elementColumnIsSettable, elementColumnWriters );
    //}
   
    return insert.toStatementString();
  }
View Full Code Here


  protected String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j) {

    // todo : remove the identityInsert param and variations;
    //   identity-insert strings are now generated from generateIdentityInsertString()

    Insert insert = new Insert( getFactory().getDialect() )
        .setTableName( getTableName( j ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, j ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    if ( j == 0 ) {
      addDiscriminatorToInsert( insert );
    }

    // add the primary key
    if ( j == 0 && identityInsert ) {
      insert.addIdentityColumn( getKeyColumns( 0 )[0] );
    }
    else {
      insert.addColumns( getKeyColumns( j ) );
    }

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    String result = insert.toStatementString();

    // append the SQL to return the generated identifier
    if ( j == 0 && identityInsert && useInsertSelectIdentity() ) { //TODO: suck into Insert
      result = getFactory().getDialect().appendIdentitySelectToInsert( result );
    }
View Full Code Here

   * @param includeProperty indices of the properties to include in the
   * insert statement.
   * @return The insert SQL statement string
   */
  protected String generateIdentityInsertString(boolean[] includeProperty) {
    Insert insert = identityDelegate.prepareIdentifierGeneratingInsert();
    insert.setTableName( getTableName( 0 ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, 0 ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    addDiscriminatorToInsert( insert );

    // delegate already handles PK columns

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    return insert.toStatementString();
  }
View Full Code Here

  protected String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j) {

    // todo : remove the identityInsert param and variations;
    //   identity-insert strings are now generated from generateIdentityInsertString()

    Insert insert = new Insert( getFactory().getDialect() )
        .setTableName( getTableName( j ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, j ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    if ( j == 0 ) {
      addDiscriminatorToInsert( insert );
    }

    // add the primary key
    if ( j == 0 && identityInsert ) {
      insert.addIdentityColumn( getKeyColumns( 0 )[0] );
    }
    else {
      insert.addColumns( getKeyColumns( j ) );
    }

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    String result = insert.toStatementString();

    // append the SQL to return the generated identifier
    if ( j == 0 && identityInsert && useInsertSelectIdentity() ) { //TODO: suck into Insert
      result = getFactory().getDialect().appendIdentitySelectToInsert( result );
    }
View Full Code Here

   * @param includeProperty indices of the properties to include in the
   * insert statement.
   * @return The insert SQL statement string
   */
  protected String generateIdentityInsertString(boolean[] includeProperty) {
    Insert insert = identityDelegate.prepareIdentifierGeneratingInsert();
    insert.setTableName( getTableName( 0 ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, 0 ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    addDiscriminatorToInsert( insert );

    // delegate already handles PK columns

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    return insert.toStatementString();
  }
View Full Code Here

  protected String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j) {

    // todo : remove the identityInsert param and variations;
    //   identity-insert strings are now generated from generateIdentityInsertString()

    Insert insert = new Insert( getFactory().getDialect() )
        .setTableName( getTableName( j ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, j ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    if ( j == 0 ) {
      addDiscriminatorToInsert( insert );
    }

    // add the primary key
    if ( j == 0 && identityInsert ) {
      insert.addIdentityColumn( getKeyColumns( 0 )[0] );
    }
    else {
      insert.addColumns( getKeyColumns( j ) );
    }

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    String result = insert.toStatementString();

    // append the SQL to return the generated identifier
    if ( j == 0 && identityInsert && useInsertSelectIdentity() ) { //TODO: suck into Insert
      result = getFactory().getDialect().appendIdentitySelectToInsert( result );
    }
View Full Code Here

   * @param includeProperty indices of the properties to include in the
   * insert statement.
   * @return The insert SQL statement string
   */
  protected String generateIdentityInsertString(boolean[] includeProperty) {
    Insert insert = identityDelegate.prepareIdentifierGeneratingInsert();
    insert.setTableName( getTableName( 0 ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, 0 ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    addDiscriminatorToInsert( insert );

    // delegate already handles PK columns

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    return insert.toStatementString();
  }
View Full Code Here

      boolean[] includeProperty, int j) {

    // todo : remove the identityInsert param and variations;
    //   identity-insert strings are now generated from generateIdentityInsertString()

    Insert insert = new Insert( getFactory().getDialect() )
        .setTableName( getTableName( j ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
     
      if ( includeProperty[i] && isPropertyOfTable( i, j )
          && !lobProperties.contains( i ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i),
            propertyColumnInsertable[i],
            propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    if ( j == 0 ) {
      addDiscriminatorToInsert( insert );
    }

    // add the primary key
    if ( j == 0 && identityInsert ) {
      insert.addIdentityColumn( getKeyColumns( 0 )[0] );
    }
    else {
      insert.addColumns( getKeyColumns( j ) );
    }

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }
   
    // HHH-4635
    // Oracle expects all Lob properties to be last in inserts
    // and updates.  Insert them at the end.
    for ( int i : lobProperties ) {
      if ( includeProperty[i] && isPropertyOfTable( i, j ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i),
            propertyColumnInsertable[i],
            propertyColumnWriters[i] );
      }
    }

    String result = insert.toStatementString();

    // append the SQL to return the generated identifier
    if ( j == 0 && identityInsert && useInsertSelectIdentity() ) { //TODO: suck into Insert
      result = getFactory().getDialect().appendIdentitySelectToInsert( result );
    }
View Full Code Here

   * @param includeProperty indices of the properties to include in the
   * insert statement.
   * @return The insert SQL statement string
   */
  protected String generateIdentityInsertString(boolean[] includeProperty) {
    Insert insert = identityDelegate.prepareIdentifierGeneratingInsert();
    insert.setTableName( getTableName( 0 ) );

    // add normal properties except lobs
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, 0 ) && !lobProperties.contains( i ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // HHH-4635 & HHH-8103
    // Oracle expects all Lob properties to be last in inserts
    // and updates.  Insert them at the end.
    for ( int i : lobProperties ) {
      if ( includeProperty[i] && isPropertyOfTable( i, 0 ) ) {
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    addDiscriminatorToInsert( insert );

    // delegate already handles PK columns

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    return insert.toStatementString();
  }
View Full Code Here

  protected String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j) {

    // todo : remove the identityInsert param and variations;
    //   identity-insert strings are now generated from generateIdentityInsertString()

    Insert insert = new Insert( getFactory().getDialect() )
        .setTableName( getTableName( j ) );

    // add normal properties
    for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
      if ( includeProperty[i] && isPropertyOfTable( i, j ) ) {
        // this property belongs on the table and is to be inserted
        insert.addColumns( getPropertyColumnNames(i), propertyColumnInsertable[i], propertyColumnWriters[i] );
      }
    }

    // add the discriminator
    if ( j == 0 ) {
      addDiscriminatorToInsert( insert );
    }

    // add the primary key
    if ( j == 0 && identityInsert ) {
      insert.addIdentityColumn( getKeyColumns( 0 )[0] );
    }
    else {
      insert.addColumns( getKeyColumns( j ) );
    }

    if ( getFactory().getSettings().isCommentsEnabled() ) {
      insert.setComment( "insert " + getEntityName() );
    }

    String result = insert.toStatementString();

    // append the SQL to return the generated identifier
    if ( j == 0 && identityInsert && useInsertSelectIdentity() ) { //TODO: suck into Insert
      result = getFactory().getDialect().appendIdentitySelectToInsert( result );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.sql.Insert

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.