Examples of EntityKey


Examples of org.hibernate.ogm.grid.EntityKey

              propertyColumnNames,
              includeColumns[propertyIndex],
              session
          );
    Object[] columnValues = LogicalPhysicalConverterHelper.getColumnValuesFromResultset( tuple, rowKeyColumnNames );
    EntityKey targetKey = associationPersister.createTargetKey( rowKeyColumnNames, columnValues );
    final RowKey rowKey = new RowKey( persister.getTableName(), rowKeyColumnNames, columnValues, targetKey );

    Tuple assocEntryTuple = associationPersister.createAndPutAssociationTuple( rowKey );
    for ( String column : tuple.getColumnNames() ) {
      assocEntryTuple.put( column, tuple.get( column ) );
View Full Code Here

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

      columnValues[i] = rowKey.getColumnValue( associationKeyColumn );
      i++;
    }

    EntityKeyMetadata entityKeyMetadata = associationKey.getMetadata().getAssociatedEntityKeyMetadata().getEntityKeyMetadata();
    return new EntityKey( entityKeyMetadata, columnValues );
  }
View Full Code Here

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

    // given
    String[] columnNames = { "foo", "bar", "baz" };
    EntityKeyMetadata keyMetadata = new EntityKeyMetadata( "Foobar", columnNames );
    Object[] values = { 123, "Hello", 456L };

    EntityKey key = new EntityKey( keyMetadata, values );

    // when
    Tuple tuple = dialect1.createTuple( key, emptyTupleContext() );
    tuple.put( "foo", "bar" );
    dialect1.insertOrUpdateTuple( key, tuple, emptyTupleContext() );
View Full Code Here

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

        throw new AssertionFailure( "Unrecognized associationKind: " + associationKey.getMetadata().getAssociationKind() );
    }
  }

  private Relationship createRelationshipWithEmbeddedNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    EntityKey entityKey = getEntityKey( associationRow, associatedEntityKeyMetadata );
    Node embeddedNode = entityQueries.get( entityKey.getMetadata() ).createEmbedded( executionEngine, entityKey.getColumnValues() );
    Relationship relationship = createRelationshipWithTargetNode( associationKey, associationRow, embeddedNode );
    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }
View Full Code Here

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

    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }

  private Relationship findOrCreateRelationshipWithEntityNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    EntityKey targetEntityKey = getEntityKey( associationRow, associatedEntityKeyMetadata );
    Node targetNode = entityQueries.get( targetEntityKey.getMetadata() ).findEntity( executionEngine, targetEntityKey.getColumnValues() );
    return createRelationshipWithTargetNode( associationKey, associationRow, targetNode );
  }
View Full Code Here

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

      relationship.setProperty( propertyName, propertyValue );
    }
  }

  private Relationship createRelationshipWithTargetNode(AssociationKey associationKey, Tuple associationRow, Node targetNode) {
    EntityKey entityKey = associationKey.getEntityKey();
    Node ownerNode = entityQueries.get( entityKey.getMetadata() ).findEntity( executionEngine, entityKey.getColumnValues() );
    Relationship relationship = ownerNode.createRelationshipTo( targetNode, withName( associationKey.getMetadata().getCollectionRole() ) );
    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }
View Full Code Here

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

    return relationship;
  }

  @Override
  public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) {
    EntityKey entityKey = associationKey.getEntityKey();
    Node entityNode = entityQueries.get( entityKey.getMetadata() ).findEntity( executionEngine, entityKey.getColumnValues() );
    GraphLogger.log( "Found owner node: %1$s", entityNode );
    if ( entityNode == null ) {
      return null;
    }
    return new Association(
View Full Code Here

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

      String associationRole = tupleContext.getRole( operation.getColumn() );

      if ( !processedAssociationRoles.contains( associationRole ) ) {
        processedAssociationRoles.add( associationRole );

        EntityKey targetKey = getEntityKey( tuple, tupleContext.getAssociatedEntityKeyMetadata( operation.getColumn() ) );

        // delete the previous relationship if there is one; for a to-one association, the relationship won't have any
        // properties, so the type is uniquely identifying it
        Iterator<Relationship> relationships = node.getRelationships( withName( associationRole ) ).iterator();
        if ( relationships.hasNext() ) {
          relationships.next().delete();
        }

        // create a new relationship
        Node targetNode = entityQueries.get( targetKey.getMetadata() ).findEntity( executionEngine, targetKey.getColumnValues() );
        node.createRelationshipTo( targetNode, withName( associationRole ) );
      }
    }
  }
View Full Code Here

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

    for ( String associationKeyColumn : associatedEntityKeyMetadata.getAssociationKeyColumns() ) {
      columnValues[i] = tuple.get( associationKeyColumn );
      i++;
    }

    return new EntityKey( associatedEntityKeyMetadata.getEntityKeyMetadata(), columnValues );
  }
View Full Code Here

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

    String[] columnNames = { "foo", "bar", "baz" };
    EntityKeyMetadata keyMetadata = new EntityKeyMetadata( "Foobar", columnNames );
    Object[] values = { 123, "Hello", 456L };

    // given
    EntityKey key = new EntityKey( keyMetadata, values );

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

    // then
    assertThat( unmarshalledKey.getTable() ).isEqualTo( key.getTable() );
    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
TOP
Copyright © 2018 www.massapi.com. 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.