Package org.hibernate.ogm.grid.impl

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


    Association propertyValues = associationPersister.getAssociation();
    if ( propertyValues != null ) {
      //Map's equals operation delegates to all it's key and value, should be fine for now
      //this is a StarToOne case ie the FK is on the owning entity
      final RowKey matchingTuple = new RowKeyBuilder()
          .tableName( persister.getTableName() )
          .addColumns( buildRowKeyColumnNamesForStarToOne( persister, propertyColumnNames ) )
          .values( tupleKey )
          .entityKey( associationPersister.createTargetKey( rowKeyColumnNames, tupleKey ) )
          .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

    getElementGridType().nullSafeSet( keyAndTuple.tuple, element, getElementColumnNames(), session );
  }

  private RowKeyAndTuple createAndPutTupleforInsert(Serializable key, PersistentCollection collection,
      AssociationPersister associationPersister, SessionImplementor session, int i, Object entry) {
    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 );
    }
    getKeyGridType().nullSafeSet( tuple, 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( tuple, incrementIndexByBase( index ), getIndexColumnNames(), session );
    }
    else {
      // use element as tuple key
      final Object element = collection.getElement( entry );
      getElementGridType().nullSafeSet( tuple, element, getElementColumnNames(), session );

    }

    RowKeyAndTuple result = new RowKeyAndTuple();
    EntityKey entityKey = associationPersister.createTargetKey( rowKeyBuilder.getColumnNames(), tuple );
    result.key = rowKeyBuilder.values( tuple ).entityKey( entityKey ).build();

    Tuple assocEntryTuple = associationPersister.createAndPutAssociationTuple( result.key );
    for ( String column : tuple.getColumnNames() ) {
      assocEntryTuple.put( column, tuple.get( column ) );
    }
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().tableName( getTableName() );
    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 );
    rowKeyBuilder.entityKey( associationPersister.createTargetKey( rowKeyBuilder.getColumnNames(), tuple ) );
    return rowKeyBuilder.build();
  }
View Full Code Here

    rowKeyBuilder.entityKey( associationPersister.createTargetKey( rowKeyBuilder.getColumnNames(), 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 );
    rowKeyBuilder.entityKey( associationPersister.createTargetKey( rowKeyBuilder.getColumnNames(), tuple ) );
    return rowKeyBuilder.build();
  }
View Full Code Here

    getElementGridType().nullSafeSet( keyAndTuple.tuple, element, getElementColumnNames(), session );
  }

  private RowKeyAndTuple createAndPutTupleforInsert(Serializable key, PersistentCollection collection,
      AssociationPersister associationPersister, SessionImplementor session, int i, Object entry) {
    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 );
    }
    getKeyGridType().nullSafeSet( tuple, 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( tuple, incrementIndexByBase( index ), getIndexColumnNames(), session );
    }
    else {
      // use element as tuple key
      final Object element = collection.getElement( entry );
      getElementGridType().nullSafeSet( tuple, element, getElementColumnNames(), session );

    }
    RowKeyAndTuple result = new RowKeyAndTuple();
    result.key = rowKeyBuilder.values( tuple ).build();
    Tuple assocEntryTuple = associationPersister.createAndPutAssociationTuple( result.key );
    for ( String column : tuple.getColumnNames() ) {
      assocEntryTuple.put( column, tuple.get( column ) );
    }
    result.tuple = assocEntryTuple;
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().tableName( getTableName() );
    if ( hasIdentifier ) {
      builder.addColumns( getIdentifierColumnName() );
    }
    else {
      builder.addColumns( getKeyColumnNames() );
      // !isOneToMany() present in delete not in update
      if ( !isOneToMany() && hasIndex && !indexContainsFormula ) {
        builder.addColumns( getIndexColumnNames() );
      }
      else {
        builder.addColumns( getElementColumnNames() );
      }
    }
    return builder;
  }
View Full Code Here

  public String[] getRowKeyColumnNames() {
    return initializeRowKeyBuilder().getColumnNames();
  }

  private RowKey getTupleKeyForUpdate(Serializable key, PersistentCollection collection, SessionImplementor session, int i, Object entry) {
    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 );
      }
    }
    return rowKeyBuilder.values( tuple ).build();
  }
View Full Code Here

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

  private RowKey getTupleKeyForDelete(Serializable key, PersistentCollection collection, SessionImplementor session, Object entry, boolean findByIndex) {
    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

TOP

Related Classes of org.hibernate.ogm.grid.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.