Package org.hibernate.ogm.model.impl

Examples of org.hibernate.ogm.model.impl.RowKeyBuilder


    else {
      gridTypeOfAssociatedId = null;
      associationType = AssociationType.OTHER;
    }

    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    String[] rowKeyColumnNames = rowKeyBuilder.getColumnNames();
    String[] rowKeyIndexColumnNames = rowKeyBuilder.getIndexColumnNames();

    associationKeyMetadata = new AssociationKeyMetadata.Builder()
        .table( getTableName() )
        .columnNames( getKeyColumnNames() )
        .rowKeyColumnNames( rowKeyColumnNames )
View Full Code Here


   * Creates an association row representing the given entry and adds it to the association managed by the given
   * persister.
   */
  private RowKeyAndTuple createAndPutAssociationRowForInsert(Serializable key, PersistentCollection collection,
      AssociationPersister associationPersister, SessionImplementor session, int i, Object entry) {
    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    Tuple associationRow = new Tuple();

    // the collection has a surrogate key (see @CollectionId)
    if ( hasIdentifier ) {
      final Object identifier = collection.getIdentifier( entry, i );
      String[] names = { getIdentifierColumnName() };
      identifierGridType.nullSafeSet( associationRow, identifier, names, session );
    }

    getKeyGridType().nullSafeSet( associationRow, key, getKeyColumnNames(), session );
    // No need to write to where as we don't do where clauses in OGM :)
    if ( hasIndex ) {
      Object index = collection.getIndex( entry, i, this );
      indexGridType.nullSafeSet( associationRow, incrementIndexByBase( index ), getIndexColumnNames(), session );
    }

    // columns of referenced key
    final Object element = collection.getElement( entry );
    getElementGridType().nullSafeSet( associationRow, element, getElementColumnNames(), session );

    RowKeyAndTuple result = new RowKeyAndTuple();
    result.key = rowKeyBuilder.values( associationRow ).build();
    result.tuple = associationRow;

    associationPersister.getAssociation().put( result.key, result.tuple );

    return result;
View Full Code Here

    Tuple tuple;
  }

  // Centralize the RowKey column setting logic as the values settings are slightly different between insert / update and delete
  private RowKeyBuilder initializeRowKeyBuilder() {
    RowKeyBuilder builder = new RowKeyBuilder();
    if ( hasIdentifier ) {
      builder.addColumns( getIdentifierColumnName() );
    }
    else {
      builder.addColumns( getKeyColumnNames() );
      // !isOneToMany() present in delete not in update
      if ( !isOneToMany() && hasIndex && !indexContainsFormula ) {
        builder.addIndexColumns( getIndexColumnNames() );
      }
      else {
        builder.addColumns( getElementColumnNames() );
      }
    }
    return builder;
  }
View Full Code Here

    }
    return builder;
  }

  private RowKey getTupleKeyForUpdate(Serializable key, PersistentCollection collection, SessionImplementor session, int i, Object entry, AssociationPersister associationPersister) {
    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    Tuple tuple = new Tuple();
    if ( hasIdentifier ) {
      final Object identifier = collection.getIdentifier( entry, i );
      String[] names = { getIdentifierColumnName() };
      identifierGridType.nullSafeSet( tuple, identifier, names, session );
    }
    else {
      getKeyGridType().nullSafeSet( tuple, key, getKeyColumnNames(), session );
      // No need to write to where as we don't do where clauses in OGM :)
      if ( !isOneToMany() && hasIndex && !indexContainsFormula ) {
        Object index = collection.getIndex( entry, i, this );
        indexGridType.nullSafeSet( tuple, incrementIndexByBase( index ), getIndexColumnNames(), session );
      }
      else {
        final Object snapshotElement = collection.getSnapshotElement( entry, i );
        if ( elementIsPureFormula ) {
          throw new AssertionFailure( "cannot use a formula-based element in the where condition" );
        }
        getElementGridType().nullSafeSet( tuple, snapshotElement, getElementColumnNames(), session );
      }
    }
    rowKeyBuilder.values( tuple );
    return rowKeyBuilder.build();
  }
View Full Code Here

    rowKeyBuilder.values( tuple );
    return rowKeyBuilder.build();
  }

  private RowKey getTupleKeyForDelete(Serializable key, PersistentCollection collection, SessionImplementor session, Object entry, boolean findByIndex, AssociationPersister associationPersister) {
    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    Tuple tuple = new Tuple();
    if ( hasIdentifier ) {
      final Object identifier = entry;
      String[] names = { getIdentifierColumnName() };
      identifierGridType.nullSafeSet( tuple, identifier, names, session );
    }
    else {
      getKeyGridType().nullSafeSet( tuple, key, getKeyColumnNames(), session );
      // No need to write to where as we don't do where clauses in OGM :)
      if ( findByIndex ) {
        Object index = entry;
        indexGridType.nullSafeSet( tuple, incrementIndexByBase( index ), getIndexColumnNames(), session );
      }
      else {
        final Object snapshotElement = entry;
        if ( elementIsPureFormula ) {
          throw new AssertionFailure( "cannot use a formula-based element in the where condition" );
        }
        getElementGridType().nullSafeSet( tuple, snapshotElement, getElementColumnNames(), session );
      }
    }
    rowKeyBuilder.values( tuple );
    return rowKeyBuilder.build();
  }
View Full Code Here

    }

    // add the id column
    persister.getGridIdentifierType().nullSafeSet( rowKeyValues, id, persister.getIdentifierColumnNames(), session );

    return new RowKeyBuilder()
      .addColumns( associationKeyMetadata.getRowKeyColumnNames() )
      .values( rowKeyValues )
      .build();
  }
View Full Code Here

    }

    // add the id column
    persister.getGridIdentifierType().nullSafeSet( rowKeyValues, id, persister.getIdentifierColumnNames(), session );

    return new RowKeyBuilder()
      .addColumns( associationKeyMetadata.getRowKeyColumnNames() )
      .values( rowKeyValues )
      .build();
  }
View Full Code Here

    else {
      gridTypeOfAssociatedId = null;
      associationType = AssociationType.OTHER;
    }

    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    String[] rowKeyColumnNames = rowKeyBuilder.getColumnNames();
    String[] rowKeyIndexColumnNames = rowKeyBuilder.getIndexColumnNames();

    associationKeyMetadata = new AssociationKeyMetadata(
        getTableName(),
        getKeyColumnNames(),
        rowKeyColumnNames,
View Full Code Here

   * Creates an association row representing the given entry and adds it to the association managed by the given
   * persister.
   */
  private RowKeyAndTuple createAndPutAssociationRowForInsert(Serializable key, PersistentCollection collection,
      AssociationPersister associationPersister, SessionImplementor session, int i, Object entry) {
    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    Tuple associationRow = new Tuple();

    // the collection has a surrogate key (see @CollectionId)
    if ( hasIdentifier ) {
      final Object identifier = collection.getIdentifier( entry, i );
      String[] names = { getIdentifierColumnName() };
      identifierGridType.nullSafeSet( associationRow, identifier, names, session );
    }

    getKeyGridType().nullSafeSet( associationRow, key, getKeyColumnNames(), session );
    // No need to write to where as we don't do where clauses in OGM :)
    if ( hasIndex ) {
      Object index = collection.getIndex( entry, i, this );
      indexGridType.nullSafeSet( associationRow, incrementIndexByBase( index ), getIndexColumnNames(), session );
    }

    // columns of referenced key
    final Object element = collection.getElement( entry );
    getElementGridType().nullSafeSet( associationRow, element, getElementColumnNames(), session );

    RowKeyAndTuple result = new RowKeyAndTuple();
    result.key = rowKeyBuilder.values( associationRow ).build();
    result.tuple = associationRow;

    associationPersister.getAssociation().put( result.key, result.tuple );

    return result;
View Full Code Here

    Tuple tuple;
  }

  // Centralize the RowKey column setting logic as the values settings are slightly different between insert / update and delete
  public RowKeyBuilder initializeRowKeyBuilder() {
    RowKeyBuilder builder = new RowKeyBuilder();
    if ( hasIdentifier ) {
      builder.addColumns( getIdentifierColumnName() );
    }
    else {
      builder.addColumns( getKeyColumnNames() );
      // !isOneToMany() present in delete not in update
      if ( !isOneToMany() && hasIndex && !indexContainsFormula ) {
        builder.addIndexColumns( getIndexColumnNames() );
      }
      else {
        builder.addColumns( getElementColumnNames() );
      }
    }
    return builder;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.model.impl.RowKeyBuilder

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.