Examples of Association


Examples of org.hibernate.ogm.model.spi.Association

    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.spi.Association

    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>();
    properties.put( "user_id", "Emmanuel" );
    properties.put( "addresses_id", 1 );
    Tuple associationTuple = new Tuple( new CouchDBTupleSnapshot( properties ) );

    RowKey rowKey = new RowKey( rowKeyColumnNames, rowKeyColumnValues );
    createAssociation.put( rowKey, associationTuple );
    dialect.insertOrUpdateAssociation( key, createAssociation, emptyAssociationContext() );

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

Examples of org.hibernate.ogm.model.spi.Association

            null
        ),
        new Tuple( new MongoDBTupleSnapshot( null, null, null ) )
    );

    final Association association = getService( GridDialect.class ).getAssociation( associationKey, associationContext );
    final MongoDBAssociationSnapshot associationSnapshot = (MongoDBAssociationSnapshot) association.getSnapshot();
    final DBObject assocObject = associationSnapshot.getDBObject();
    this.checkLoading( assocObject );

    session.delete( mongodb );
    session.delete( infinispan );
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

        .associationKeyMetadata( persister.getAssociationKeyMetadata() )
        .associationTypeContext( persister.getAssociationTypeContext() )
        .hostingEntity( owner )
        .session( session );

      Association assoc = associationPersister.getAssociationOrNull();
      if ( assoc != null ) {
        for ( RowKey rowKey : assoc.getKeys() ) {
          resultset.addTuple( assoc.get( rowKey ) );
        }
      }
    }
    return resultset;
  }
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

  }

  @Override
  public int getSize(Serializable key, SessionImplementor session) {
    AssociationPersister associationPersister = getAssociationPersister( session.getPersistenceContext().getEntity( new org.hibernate.engine.spi.EntityKey( key, getOwnerEntityPersister() ) ), key, session );
    final Association collectionMetadata = associationPersister.getAssociationOrNull();

    return collectionMetadata == null ? 0 : collectionMetadata.size();
  }
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

      Object owner = session.getPersistenceContext().getCollectionOwner( id, this );

      // Remove all the old entries
      AssociationPersister associationPersister = getAssociationPersister( owner, id, session );
      Association association = associationPersister.getAssociationOrNull();

      if ( association != null ) {
        // shortcut to avoid loop if we can
        if ( associationType != AssociationType.OTHER ) {
          for ( RowKey assocEntryKey : association.getKeys() ) {
            // we unfortunately cannot mass change the update of the associated entity
            updateInverseSideOfAssociationNavigation(
                session,
                null,
                association.get( assocEntryKey ),
                Action.REMOVE,
                assocEntryKey
                );
          }
        }
        association.clear();

        associationPersister.flushToDatastore();
      }

      if ( log.isDebugEnabled() ) {
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

    log( "removeTuple", key.toString(), "VOID" );
  }

  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    Association association = super.getAssociation( key, associationContext );
    log( "getAssociation", key.toString(), toShortString( association ) );
    return association;
  }
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

    return association;
  }

  @Override
  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    Association association = super.createAssociation( key, associationContext );
    log( "createAssociation", key.toString(), toShortString( association ) );
    return association;
  }
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

    executeBatch( associationContext.getOperationsQueue() );
    if ( storageStrategy == AssociationStorageStrategy.IN_ENTITY ) {
      DBObject entity = getEmbeddingEntity( key, associationContext );

      if ( entity != null && hasField( entity, key.getMetadata().getCollectionRole() ) ) {
        return new Association( new MongoDBAssociationSnapshot( entity, key, storageStrategy ) );
      }
      else {
        return null;
      }
    }
    final DBObject result = findAssociation( key, associationContext, storageStrategy );
    if ( result == null ) {
      return null;
    }
    else {
      return new Association( new MongoDBAssociationSnapshot( result, key, storageStrategy ) );
    }
  }
View Full Code Here

Examples of org.hibernate.ogm.model.spi.Association

    DBObject document = storageStrategy == AssociationStorageStrategy.IN_ENTITY
        ? getEmbeddingEntity( key, associationContext )
        : associationKeyToObject( key, storageStrategy );

    return new Association( new MongoDBAssociationSnapshot( document, key, storageStrategy ) );
  }
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.