Examples of EntityKeyMetadata


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

  @Test
  public void shouldSerializeAndDeserializeEntityKey() throws Exception {
    // given
    String[] columnNames = { "foo", "bar", "baz" };
    EntityKeyMetadata keyMetadata = new EntityKeyMetadata( "Foobar", columnNames );

    // when
    byte[] bytes = externalizerHelper.marshall( keyMetadata );
    EntityKeyMetadata unmarshalledMetadata = externalizerHelper.unmarshall( bytes );

    // then
    assertThat( unmarshalledMetadata.getClass() ).isEqualTo( EntityKeyMetadata.class );
    assertThat( unmarshalledMetadata.getTable() ).isEqualTo( keyMetadata.getTable() );
    assertThat( unmarshalledMetadata.getColumnNames() ).isEqualTo( keyMetadata.getColumnNames() );

    assertTrue( keyMetadata.equals( unmarshalledMetadata ) );
    assertTrue( unmarshalledMetadata.equals( keyMetadata ) );
    assertThat( unmarshalledMetadata.hashCode() ).isEqualTo( keyMetadata.hashCode() );
  }
View Full Code Here

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

  }

  @Test
  public void shouldSerializeAndDeserializeEntityKey() throws Exception {
    String[] columnNames = { "foo", "bar", "baz" };
    EntityKeyMetadata keyMetadata = new EntityKeyMetadata( "Foobar", columnNames );
    Object[] values = { 123, "Hello", 456L };

    // given
    EntityKey key = new EntityKey( keyMetadata, values );
View Full Code Here

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

    Association actualAssociation = dialect.getAssociation( key, emptyAssociationContext() );
    assertThat( actualAssociation.get( rowKey ).hashCode() ).isNotNull();
  }

  private EntityKey createEntityKey(String tableName, String[] columnNames, Object[] values) {
    return new EntityKey( new EntityKeyMetadata( tableName, columnNames ), values );
  }
View Full Code Here

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

    this.addExtraColumn();
    AssociationKeyMetadata metadata = new AssociationKeyMetadata.Builder()
        .table( "Project_Module" )
        .columnNames( new String[] { "Project_id" } )
        .rowKeyColumnNames( new String[] { "Project_id", "module_id" } )
        .associatedEntityKeyMetadata( new AssociatedEntityKeyMetadata( new String[] { "module_id" }, new EntityKeyMetadata( "Module", new String[] { "id" } ) ) )
        .inverse( false )
        .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" }
        )
    );

    AssociationContext associationContext = new AssociationContextImpl(
View Full Code Here

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

    session.close();
  }

  private Tuple getTuple(String collectionName, String id, List<String> selectedColumns) {
    EntityKey key = new EntityKey(
        new EntityKeyMetadata( collectionName, new String[] { MongoDBDialect.ID_FIELDNAME } ),
        new Object[] { id }
    );
    TupleContext tupleContext = new TupleContextImpl(
        selectedColumns,
        Collections.<String, AssociatedEntityKeyMetadata>emptyMap(),
View Full Code Here

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

        targetColumnNames = getKeyColumnNames();
      }
      else {
        targetColumnNames = getElementColumnNames();
      }
      return new EntityKeyMetadata( getTableName(), targetColumnNames );
    }
  }
View Full Code Here

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

    input.readInt();

    String tableName = input.readUTF();
    String[] columnNames = (String[]) input.readObject();

    return new EntityKeyMetadata( tableName, columnNames );
  }
View Full Code Here

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

    String tableName = input.readUTF();
    String[] columnNames = (String[]) input.readObject();
    Object[] values = (Object[]) input.readObject();

    return new EntityKey( new EntityKeyMetadata( tableName, columnNames ), values );
  }
View Full Code Here

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

    this.monitor = monitor;
  }

  private EntityKeyMetadata getEntityKeyMetadata() {
    OgmEntityPersister persister = (OgmEntityPersister) sessionFactory.getEntityPersister( indexedType.getName() );
    return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
  }
View Full Code Here

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

  @Override
  public void run() {
    ErrorHandler errorHandler = searchFactory.getErrorHandler();
    try {
      final EntityKeyMetadata keyMetadata = getEntityKeyMetadata();
      final SessionAwareRunnable consumer = new TupleIndexer( indexedType, monitor, sessionFactory, searchFactory, cacheMode, batchBackend, errorHandler );
      gridDialect.forEachTuple( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, consumer ), keyMetadata );
    }
    catch ( RuntimeException re ) {
      // being this an async thread we want to make sure everything is somehow reported
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.