Package org.hibernate.ogm.model.spi

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


  }

  @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

      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

    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

    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

    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

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

    return new Association( new MongoDBAssociationSnapshot( document, key, storageStrategy ) );
  }
View Full Code Here

  }

  private void removeNavigationalInformationFromInverseSide(int propertyIndex, AssociationKeyMetadata associationKeyMetadata, Object[] oldColumnValue) {
    AssociationPersister associationPersister = createAssociationPersister( propertyIndex, associationKeyMetadata, oldColumnValue );

    Association association = associationPersister.getAssociationOrNull();

    if ( association != null ) {
      RowKey rowKey = getInverseRowKey( associationKeyMetadata, oldColumnValue );
      association.remove( rowKey );
      associationPersister.flushToDatastore();
    }
  }
View Full Code Here

  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    Cache<AssociationKey, Map<RowKey, Map<String, Object>>> cache = provider.getCache( ASSOCIATION_CACHE );
    Map<RowKey, Map<String, Object>> atomicMap = AtomicMapLookup.getFineGrainedAtomicMap( cache, key, false );
    return atomicMap == null ? null : new Association( new MapAssociationSnapshot( atomicMap ) );
  }
View Full Code Here

  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    //TODO we don't verify that it does not yet exist assuming that this ahs been done before by the calling code
    //should we improve?
    Cache<AssociationKey, Map<RowKey, Map<String, Object>>> cache = provider.getCache( ASSOCIATION_CACHE );
    Map<RowKey, Map<String, Object>> atomicMap = AtomicMapLookup.getFineGrainedAtomicMap( cache, key, true );
    return new Association( new MapAssociationSnapshot( atomicMap ) );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.model.spi.Association

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.