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

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


        .build();

    Object[] values = { 123, "Hello", 456L };

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

    // when
    byte[] bytes = externalizerHelper.marshall( key );
    AssociationKey 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


        .columnNames( columnNames )
        .associatedEntityKeyMetadata( new AssociatedEntityKeyMetadata( null, null ) )
        .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" );
View Full Code Here

    String[] columnNames = { "id" };
    String[] rowKeyColumnNames = new String[] { "id" };
    EntityKey entityKey = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    String collectionRole = "addresses";

    AssociationKey key = createAssociationKey( entityKey, collectionRole, tableName, columnNames, columnValues, rowKeyColumnNames );

    Association createAssociation = dialect.createAssociation( key, emptyAssociationContext() );

    assertThat( createAssociation.getSnapshot() ).isNotNull();
    assertThat( createAssociation.getSnapshot().getRowKeys() ).isEmpty();
View Full Code Here

    Object[] rowKeyColumnValues = new Object[] { "Emmanuel", 1 };
    EntityKey entityKey = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    Tuple tuple = dialect.createTuple( entityKey, emptyTupleContext() );
    dialect.insertOrUpdateTuple( entityKey, tuple, emptyTupleContext() );

    AssociationKey key = createAssociationKey(
        entityKey, "addresses", "user_address", new String[] { "user_id" }, new Object[] { "Emmanuel" }, rowKeyColumnNames
    );
    Association createAssociation = dialect.createAssociation( key, emptyAssociationContext() );

    Map<String, Object> properties = new HashMap<String, Object>();
View Full Code Here

      .collectionRole( collectionRole )
      .associationKind( AssociationKind.ASSOCIATION )
      .oneToOne( false )
      .build();

    return new AssociationKey( associationKeyMetadata, columnValues, ownerEntityKey );
  }
View Full Code Here

        .collectionRole( "modules" )
        .associationKind( AssociationKind.ASSOCIATION )
        .oneToOne( false )
        .build();

    AssociationKey associationKey = new AssociationKey(
        metadata,
        new Object[] { "projectID" },
        new EntityKey(
            new EntityKeyMetadata( "Project", new String[] { "id" } ),
            new String[] { "projectID" }
View Full Code Here

        .columnNames( columnNames )
        .build();

    // the engine never accesses deserialized key instances so it's ok to leave the additional attributes
    // null; we should still consider extract these attributes to avoid potential confusion
    return new AssociationKey( associationKeyMetadata, values, null );
  }
View Full Code Here

            ((OgmEntityPersister) getHostingEntityPersister()).getEntityKeyMetadata(),
            columnValues
        );
      }

      associationKey = new AssociationKey( associationKeyMetadata, columnValues, ownerEntityKey );
    }

    return associationKey;
  }
View Full Code Here

  /*
   * Load a collection and create it if it is not found
   */
  public Association getAssociation() {
    if ( association == null ) {
      AssociationKey key = getAssociationKey();
      association = gridDialect.getAssociation( key, getAssociationContext() );
      if (association == null) {
        association = gridDialect.createAssociation( key, getAssociationContext() );
      }
    }
View Full Code Here

    AssociationKeyMetadata associationKeyMetadata = new AssociationKeyMetadata( tableName, columnNames, null, null, null, false, null, null );

    // the engine never accesses deserialized key instances so it's ok to leave the additional attributes
    // null; we should still consider extract these attributes to avoid potential confusion
    return new AssociationKey( associationKeyMetadata, values, null );
  }
View Full Code Here

TOP

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

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.