Package org.hibernate.ogm.model.key.spi

Examples of org.hibernate.ogm.model.key.spi.RowKey


        .build();
    Object[] values = { 123, "Hello", 456L };

    AssociationKey key = new AssociationKey( keyMetadata, values, null );

    RowKey rowKey = new RowKey( columnNames, values );
    Tuple tuple = new Tuple();
    tuple.put( "zip", "zap" );

    // when
    Association association = dialect1.createAssociation( key, null );
View Full Code Here


  public void shouldSerializeAndDeserializeRowKey() throws Exception {
    String[] columnNames = { "foo", "bar", "baz" };
    Object[] values = { 123, "Hello", 456L };

    // given
    SerializableRowKey key = new SerializableRowKey( new RowKey( columnNames, values ) );

    // when
    byte[] bytes = marshall( key );
    SerializableRowKey unmarshalledKey = unmarshall( bytes );
View Full Code Here

  public void shouldSerializeAndDeserializeRowKey() throws Exception {
    String[] columnNames = { "foo", "bar", "baz" };
    Object[] values = { 123, "Hello", 456L };

    // given
    RowKey key = new RowKey( columnNames, values );

    // when
    byte[] bytes = externalizerHelper.marshall( key );
    RowKey unmarshalledKey = externalizerHelper.unmarshall( bytes );

    // then
    assertThat( unmarshalledKey.getColumnNames() ).isEqualTo( key.getColumnNames() );
    assertThat( unmarshalledKey.getColumnValues() ).isEqualTo( key.getColumnValues() );

    assertTrue( key.equals( unmarshalledKey ) );
    assertTrue( unmarshalledKey.equals( key ) );
    assertThat( unmarshalledKey.hashCode() ).isEqualTo( key.hashCode() );
  }
View Full Code Here

  public Neo4jAssociationSnapshot(Node ownerNode, AssociationKey associationKey, AssociatedEntityKeyMetadata associatedEntityKeyMetadata, String relationshipType) {
    Contracts.assertParameterNotNull( relationshipType, "relationshipType" );

    for ( Relationship relationship : relationships( ownerNode, associationKey, relationshipType ) ) {
      Neo4jTupleAssociationSnapshot snapshot = new Neo4jTupleAssociationSnapshot( relationship, associationKey, associatedEntityKeyMetadata );
      RowKey rowKey = convert( associationKey, snapshot );
      tuples.put( rowKey, new Tuple( snapshot ) );
    }
  }
View Full Code Here

    for ( int i = 0; i < columnNames.length; i++ ) {
      values[i] = snapshot.get( columnNames[i] );
    }

    return new RowKey( columnNames, values );
  }
View Full Code Here

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "user_id", "Emmanuel" );
    properties.put( "addresses_id", 1 );
    Tuple associationTuple = new Tuple( new CouchDBTupleSnapshot( properties ) );

    RowKey rowKey = new RowKey( rowKeyColumnNames, rowKeyColumnValues );
    createAssociation.put( rowKey, associationTuple );
    dialect.insertOrUpdateAssociation( key, createAssociation, emptyAssociationContext() );

    Association actualAssociation = dialect.getAssociation( key, emptyAssociationContext() );
    assertThat( actualAssociation.get( rowKey ).hashCode() ).isNotNull();
View Full Code Here

  @Override
  public Set<RowKey> getRowKeys() {
    Set<RowKey> rowKeys = new HashSet<RowKey>( associationMap.size() );

    for ( SerializableRowKey key : associationMap.keySet() ) {
      rowKeys.add( new RowKey( key.getColumnNames(), key.getColumnValues() ) );
    }

    return rowKeys;
  }
View Full Code Here

    while ( entries.hasNext() ) {
      Object entry = entries.next();
      if ( collection.needsUpdating( entry, i, elementType ) ) {
        // find the matching element
        RowKey assocEntryKey = getTupleKeyForUpdate( key, collection, session, i, entry, associationPersister );
        Tuple assocEntryTuple = associationPersister.getAssociation().get( assocEntryKey );
        if ( assocEntryTuple == null ) {
          throw new AssertionFailure( "Updating a collection tuple that is not present: " + "table {" + getTableName() + "} collectionKey {" + key + "} entry {" + entry + "}" );
        }
        // update the matching element
View Full Code Here

      if ( deletes.hasNext() ) {
        int count = 0;
        while ( deletes.hasNext() ) {
          Object entry = deletes.next();
          // find the matching element
          RowKey assocEntryKey = getTupleKeyForDelete( id, collection, session, entry, deleteByIndex, associationPersister );
          Tuple assocEntryTuple = associationPersister.getAssociation().get( assocEntryKey );
          if ( assocEntryTuple == null ) {
            throw new AssertionFailure( "Deleting a collection tuple that is not present: " + "table {" + getTableName() + "} collectionKey {" + id + "} entry {" + entry + "}" );
          }
          // delete the tuple
View Full Code Here

      AssociationPersister associationPersister = inverseCollectionPersister.getAssociationPersister( entity, elementColumnValues, session );

      // TODO what happens when a row should be *updated* ?: I suspect ADD works OK as it's a put()
      if ( action == Action.ADD ) {
        RowKey inverseRowKey = getInverseRowKey( associationRow );

        Tuple inverseAssociationRow = new Tuple();
        associationPersister.getAssociation().put( inverseRowKey, inverseAssociationRow );
        for ( String columnName : associationRow.getColumnNames() ) {
          inverseAssociationRow.put( columnName, associationRow.get( columnName ) );
        }
        associationPersister.getAssociation().put( inverseRowKey, inverseAssociationRow );
      }
      else if ( action == Action.REMOVE ) {
        // we try and match the whole tuple as it should be on both sides of the navigation
        if ( rowKey == null ) {
          throw new AssertionFailure( "Deleting a collection tuple that is not present: " + "table {"
              + getTableName() + "} key column names {" + Arrays.toString( elementColumnNames )
              + "} key column values {" + Arrays.toString( elementColumnValues ) + "}" );
        }

        RowKey inverseRowKey = getInverseRowKey( associationRow );
        associationPersister.getAssociation().remove( inverseRowKey );
      }
      else {
        throw new AssertionFailure( "Unknown action type: " + action );
      }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.model.key.spi.RowKey

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.