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

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


  }

  @Test
  public void shouldSerializeAndDeserializeAssociationKey() throws Exception {
    String[] columnNames = { "foo", "bar", "baz" };
    AssociationKeyMetadata keyMetadata = new AssociationKeyMetadata.Builder()
        .table( "Foobar" )
        .columnNames( columnNames )
        .build();

    Object[] values = { 123, "Hello", 456L };
View Full Code Here


  @Test
  public void shouldWriteAndReadAssociationInClusteredMode() throws Exception {
    // given
    String[] columnNames = { "foo", "bar", "baz" };
    AssociationKeyMetadata keyMetadata = new AssociationKeyMetadata.Builder()
        .table( "Foobar" )
        .columnNames( columnNames )
        .associatedEntityKeyMetadata( new AssociatedEntityKeyMetadata( null, null ) )
        .build();
    Object[] values = { 123, "Hello", 456L };
View Full Code Here

    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

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

  private AssociationKey createAssociationKey(EntityKey ownerEntityKey, String collectionRole, String tableName, String[] columnNames, Object[] columnValues, String[] rowKeyColumnNames) {
    AssociationKeyMetadata associationKeyMetadata = new AssociationKeyMetadata.Builder()
      .table( tableName )
      .columnNames( columnNames )
      .rowKeyColumnNames( rowKeyColumnNames )
      .associatedEntityKeyMetadata( new AssociatedEntityKeyMetadata( EMPTY_STRING_ARRAY, null ) )
      .inverse( false )
View Full Code Here

    session.persist( hibernateOGM );
    transaction.commit();

    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 )
View Full Code Here

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

    AssociationKeyMetadata associationKeyMetadata = new AssociationKeyMetadata.Builder()
        .table( tableName )
        .columnNames( columnNames )
        .build();

    // the engine never accesses deserialized key instances so it's ok to leave the additional attributes
View Full Code Here

    String mainSideProperty = mainSidePersister.getPropertyNames()[propertyIndex];

    // property is a one-to-one association (a many-to-one cannot be on the inverse side) -> get the meta-data
    // straight from the main-side persister
    AssociationKeyMetadata inverseOneToOneMetadata = mainSidePersister.getInverseOneToOneAssociationKeyMetadata( mainSideProperty );
    if ( inverseOneToOneMetadata != null ) {
      return inverseOneToOneMetadata;
    }

    // process properties of inverse side and try to find association back to main side
View Full Code Here

      log.trace( "Adding inverse navigational information for entity: " + MessageHelper.infoString( persister, id, persister.getFactory() ) );
    }

    for ( int propertyIndex = 0; propertyIndex < persister.getEntityMetamodel().getPropertySpan(); propertyIndex++ ) {
      if ( persister.isPropertyOfTable( propertyIndex, tableIndex ) ) {
        AssociationKeyMetadata associationKeyMetadata = getInverseAssociationKeyMetadata( propertyIndex );

        // there is no inverse association for the given property
        if ( associationKeyMetadata == null ) {
          continue;
        }
View Full Code Here

      log.trace( "Removing inverse navigational information for entity: " + MessageHelper.infoString( persister, id, persister.getFactory() ) );
    }

    for ( int propertyIndex = 0; propertyIndex < persister.getEntityMetamodel().getPropertySpan(); propertyIndex++ ) {
      if ( persister.isPropertyOfTable( propertyIndex, tableIndex ) ) {
        AssociationKeyMetadata associationKeyMetadata = getInverseAssociationKeyMetadata( propertyIndex );

        // there is no inverse association for the given property
        if ( associationKeyMetadata == null ) {
          continue;
        }
View Full Code Here

      OgmEntityPersister otherSidePersister = (OgmEntityPersister) ( (EntityType) propertyType).getAssociatedJoinable( getFactory() );
      String inverseOneToOneProperty = getInverseOneToOneProperty( property, otherSidePersister );

      if ( inverseOneToOneProperty != null ) {
        AssociationKeyMetadata metadata = new AssociationKeyMetadata.Builder()
            .table( getTableName() )
            .columnNames( propertyColumnNames )
            .rowKeyColumnNames( rowKeyColumnNames )
            .associatedEntityKeyMetadata( new AssociatedEntityKeyMetadata( entityKeyMetadata.getColumnNames(), entityKeyMetadata ) )
            .inverse( true )
View Full Code Here

TOP

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

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.