Package org.hibernate.ogm.datastore.spi

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


  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_STORE );
    Map<RowKey, Map<String, Object>> atomicMap = AtomicMapLookup.getFineGrainedAtomicMap( cache, key, true );
    return new Association( new MapAssociationSnapshot( atomicMap ) );
  }
View Full Code Here


    // been created
    executeBatch( associationContext.getOperationsQueue() );
    if ( storageStrategy == AssociationStorageStrategy.IN_ENTITY ) {
      DBObject entity = getEmbeddingEntity( key, associationContext );
      if ( getAssociationFieldOrNull( key, entity ) != null ) {
        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

          this.getCollection( key.getEntityKey() ).update( entity, updater, true, false, writeConcern );
          //adding assoc after update because the query takes the whole object today
          addEmptyAssociationField( key, entity );
        }
      }
      return new Association( new MongoDBAssociationSnapshot( entity, key, storageStrategy ) );
    }
    DBCollection associations = getAssociationCollection( key, storageStrategy );
    DBObject assoc = associationKeyToObject( key, storageStrategy );

    assoc.put( ROWS_FIELDNAME, Collections.EMPTY_LIST );

    associations.insert( assoc, writeConcern );

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

  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    Cache<AssociationKey, Map<RowKey, Map<String, Object>>> cache = provider.getCache(ASSOCIATION_STORE);
    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) {
    //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_STORE);
    Map<RowKey, Map<String, Object>> atomicMap =  AtomicMapLookup.getFineGrainedAtomicMap( cache, key, true );
    return new Association( new MapAssociationSnapshot( atomicMap ) );
  }
View Full Code Here

  public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) {
    Node entityNode = findNode( associationKey.getEntityKey() );
    if ( entityNode == null ) {
      return null;
    }
    return new Association( new Neo4jAssociationSnapshot( entityNode, relationshipType( associationKey ), associationKey ) );
  }
View Full Code Here

    return new Association( new Neo4jAssociationSnapshot( entityNode, relationshipType( associationKey ), associationKey ) );
  }

  @Override
  public Association createAssociation(AssociationKey associationKey, AssociationContext associationContext) {
    return new Association();
  }
View Full Code Here

        .keyGridType( gridUniqueKeyType )
        //does not set .collectionPersister as it does not make sense here for an entity
        .associationKeyMetadata( associationKeyMetadata )
        .session( session )
        .propertyType( getPropertyTypes()[propertyIndex] );
    final Association ids = associationPersister.getAssociationOrNull();

    if (ids == null || ids.size() == 0 ) {
      return null;
    }
    else if (ids.size() == 1) {
      //EntityLoader#loadByUniqueKey uses a null object and LockMode.NONE
      //there is only one element in the list, so get the first
      Tuple tuple = ids.get( ids.getKeys().iterator().next() );
      final Serializable id = (Serializable) getGridIdentifierType().nullSafeGet( tuple, getIdentifierColumnNames(), session, null );
      return load( id, null, LockMode.NONE, session );
    }
    else {
      throw new AssertionFailure(
View Full Code Here

  }

  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    Map<RowKey, Map<String, Object>> associationMap = provider.getAssociation( key );
    return associationMap == null ? null : new Association( new MapAssociationSnapshot( associationMap ) );
  }
View Full Code Here

  @Override
  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    Map<RowKey, Map<String, Object>> associationMap = new HashMap<RowKey, Map<String,Object>>();
    provider.putAssociation( key, associationMap );
    return new Association( new MapAssociationSnapshot( associationMap ) );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.datastore.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.