Package org.hibernate.ogm.grid.impl

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


    }
    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


    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 )
          .build();
      //TODO what should we do if that's null?
View Full Code Here

      }
    }
  }

  private RowKey buildRowKey(Map<String, Object> newTupleId) {
    RowKeyBuilder rowKeyBuilder = new RowKeyBuilder();
    rowKeyBuilder
        .tableName( getTableName() )
        .values( newTupleId );
    //Order matters and should be respected
    if ( hasIdentifier ) {
      rowKeyBuilder.addColumns( getIdentifierColumnName() );
    }
    rowKeyBuilder.addColumns( getKeyColumnNames() );
    //No need to write to where as we don't do where clauses in OGM :)
    if ( hasIndex ) {
      rowKeyBuilder.addColumns( getIndexColumnNames() );
    }
    else {
      //use element as tuple key
      rowKeyBuilder.addColumns( getElementColumnNames() );
    }
    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

  }

  private RowKeyAndTuple createAndPutTupleforInsert(Serializable key, PersistentCollection collection,
                            PropertyMetadataProvider metadataProvider,
                            SessionImplementor session, int i, Object entry) {
    RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
    Tuple tuple = new Tuple( EmptyTupleSnapshot.SINGLETON );
    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 = metadataProvider.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() );
      if ( !isOneToMany() && hasIndex && !indexContainsFormula ) {   //!isOneToMany() present in delete not in update
        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( EmptyTupleSnapshot.SINGLETON );
    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

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.