Examples of AssociationKey


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

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

        .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

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

    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

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

    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

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

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

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

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

        .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

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

        .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

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

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

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

    return associationKey;
  }
View Full Code Here

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

  /*
   * 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

Examples of org.hibernate.persister.walking.spi.AssociationKey

            int columnPosition = currentColumnPosition;
            currentColumnPosition += type.getColumnSpan( sessionFactory() );

            if ( type.isAssociationType() ) {
              // we build the association-key here because of the "goofiness" with 'currentColumnPosition'
              final AssociationKey associationKey;
              final AssociationType aType = (AssociationType) type;
              final Joinable joinable = aType.getAssociatedJoinable( sessionFactory() );

              if ( aType.isAnyType() ) {
                associationKey = new AssociationKey(
                    JoinHelper.getLHSTableName(
                        aType,
                        attributeNumber(),
                        (OuterJoinLoadable) locateOwningPersister()
                    ),
                    JoinHelper.getLHSColumnNames(
                        aType,
                        attributeNumber(),
                        columnPosition,
                        (OuterJoinLoadable) locateOwningPersister(),
                        sessionFactory()
                    )
                );
              }
              else if ( aType.getForeignKeyDirection() == ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT ) {
                final String lhsTableName;
                final String[] lhsColumnNames;

                if ( joinable.isCollection() ) {
                  final QueryableCollection collectionPersister = (QueryableCollection) joinable;
                  lhsTableName = collectionPersister.getTableName();
                  lhsColumnNames = collectionPersister.getElementColumnNames();
                }
                else {
                  final OuterJoinLoadable entityPersister = (OuterJoinLoadable) locateOwningPersister();
                  lhsTableName = getLHSTableName( aType, attributeNumber(), entityPersister );
                  lhsColumnNames = getLHSColumnNames(
                      aType,
                      attributeNumber(),
                      columnPosition,
                      entityPersister,
                      sessionFactory()
                  );
                }
                associationKey = new AssociationKey( lhsTableName, lhsColumnNames );
              }
              else {
                associationKey = new AssociationKey(
                    joinable.getTableName(),
                    getRHSColumnNames( aType, sessionFactory() )
                );
              }
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.