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

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


    return SingleEntityQueryBuilder.getInstance( new Neo4jPredicateFactory( propertyHelper, resolverDelegate ), propertyHelper );
  }

  private EntityKeyMetadata getKeyMetaData(Class<?> entityType) {
    OgmEntityPersister persister = (OgmEntityPersister) ( sessionFactory ).getEntityPersister( entityType.getName() );
    return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
  }
View Full Code Here


    for ( String associationKeyColumn : associationKeyColumns ) {
      columnValues[i] = rowKey.getColumnValue( associationKeyColumn );
      i++;
    }

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

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

    EntityKey key = new EntityKey( keyMetadata, values );

    // when
View Full Code Here

  private Map<EntityKeyMetadata, Neo4jEntityQueries> initializeEntityQueries(SessionFactoryImplementor sessionFactoryImplementor,
      Map<AssociationKeyMetadata, Neo4jAssociationQueries> associationQueries) {
    Map<EntityKeyMetadata, Neo4jEntityQueries> entityQueries = initializeEntityQueries( sessionFactoryImplementor );
    for ( AssociationKeyMetadata associationKeyMetadata : associationQueries.keySet() ) {
      EntityKeyMetadata entityKeyMetadata = associationKeyMetadata.getAssociatedEntityKeyMetadata().getEntityKeyMetadata();
      if ( !entityQueries.containsKey( entityKeyMetadata ) ) {
        // Embeddables metadata
        entityQueries.put( entityKeyMetadata, new Neo4jEntityQueries( entityKeyMetadata ) );
      }
    }
View Full Code Here

    Map<AssociationKeyMetadata, Neo4jAssociationQueries> queryMap = new HashMap<AssociationKeyMetadata, Neo4jAssociationQueries>();
    Collection<CollectionPersister> collectionPersisters = sessionFactoryImplementor.getCollectionPersisters().values();
    for ( CollectionPersister collectionPersister : collectionPersisters ) {
      if ( collectionPersister instanceof OgmCollectionPersister ) {
        OgmCollectionPersister ogmCollectionPersister = (OgmCollectionPersister) collectionPersister;
        EntityKeyMetadata ownerEntityKeyMetadata = ( (OgmEntityPersister) ( ogmCollectionPersister.getOwnerEntityPersister() ) ).getEntityKeyMetadata();
        AssociationKeyMetadata associationKeyMetadata = ogmCollectionPersister.getAssociationKeyMetadata();
        queryMap.put( associationKeyMetadata, new Neo4jAssociationQueries( ownerEntityKeyMetadata, associationKeyMetadata ) );
      }
    }
    return queryMap;
View Full Code Here

  @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

  }

  @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

    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

    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

    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

TOP

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

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.