Package org.hibernate.ogm.datastore.spi

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


  @Override
  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    final Cache<SerializableKey> associationCache = datastoreProvider.getAssociationCache();
    Map<SerializableKey, Map<String, Object>> association = new HashMap<SerializableKey, Map<String, Object>>();
    associationCache.put( new Element( new SerializableKey( key ), association ) );
    return new Association( new SerializableMapAssociationSnapshot( association ) );
  }
View Full Code Here


  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    if ( isEmbeddedInEntity( key, provider.getAssociationStorage() ) ) {
      DBObject entity = getObjectAsEmbeddedAssociation( key );
      if ( getAssociationFieldOrNull( key, entity ) != null ) {
        return new Association( new MongoDBAssociationSnapshot( entity, key, provider.getAssociationStorage() ) );
      }
      else {
        return null;
      }
    }
    final DBObject result = findAssociation( key );
    if ( result == null ) {
      return null;
    }
    else {
      return new Association( new MongoDBAssociationSnapshot( result, key, provider.getAssociationStorage() ) );
    }
  }
View Full Code Here

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

    assoc.put( ROWS_FIELDNAME, Collections.EMPTY_LIST );
    associations.insert( assoc );

    return new Association( new MongoDBAssociationSnapshot( assoc, key, provider.getAssociationStorage() ) );
  }
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, 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

  @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, 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

      return null;
    }
    else {
      @SuppressWarnings("unchecked")
      Map<SerializableKey, Map<String, Object>> associationRows = (Map<SerializableKey, Map<String, Object>>) element.getObjectValue();
      return new Association( new SerializableMapAssociationSnapshot( associationRows ) );
    }
  }
View Full Code Here

  @Override
  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    final Cache<SerializableKey> associationCache = datastoreProvider.getAssociationCache();
    Map<SerializableKey, Map<String, Object>> association = new HashMap<SerializableKey, Map<String, Object>>();
    associationCache.put( new Element( new SerializableKey( key ), association ) );
    return new Association( new SerializableMapAssociationSnapshot( association ) );
  }
View Full Code Here

    final Element element = associationCache.get( key );
    if ( element == null ) {
      return null;
    }
    else {
      return new Association( new MapAssociationSnapshot( (Map) element.getValue() ) );
    }
  }
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.