Package com.mongodb

Examples of com.mongodb.DBCollection.update()


        if (value instanceof MongoUpdateWritable) {
            //ignore the key - just use the update directly.
            MongoUpdateWritable muw = (MongoUpdateWritable) value;
            try {
                DBCollection dbCollection = getDbCollectionByRoundRobin();
                dbCollection.update(new BasicDBObject(muw.getQuery()), new BasicDBObject(muw.getModifiers()), muw.isUpsert(),
                                    muw.isMultiUpdate());
                return;
            } catch (final MongoException e) {
                throw new IOException("can't write to mongo", e);
            }
View Full Code Here


    protected void saveModelChanges(String objectID, ModelChanges<T> modelChanges) {
        Assert.isInstanceOf(MongoModelChanges.class, modelChanges);
        MongoModelChanges<T> mongoModelChanges = (MongoModelChanges<T>) modelChanges;

        DBCollection primaryCollection = getPrimaryCollection();
        primaryCollection.update(new QueryMongoDBObject().forID(objectID), mongoModelChanges.toDBObject(), false, false, WriteConcern.SAFE);
    }

    @Timed
    @ExceptionMetered
    public void delete(T object) {
View Full Code Here

    doc.put("destination", message.getDestination());
    doc.put("reference", message.getReference());
    doc.put("modificationTime", message.getModificationTime());
    doc.put("properties", message.getProperties());

    col.update(idObject, doc);
  }

  @Override
  public void updateStatus(MessageCriteria criteria, byte newStatus) throws StoreException {
    if (mongo == null) throw new IllegalStateException("No mongo specified");
View Full Code Here

                for (String key : keys) {
                    cachedDocs.put(key, nodesCache.getIfPresent(new StringValue(key)));
                }
            }
            try {
                WriteResult writeResult = dbCollection.update(query.get(), update, false, true);
                if (writeResult.getError() != null) {
                    throw new DocumentStoreException("Update failed: " + writeResult.getError());
                }
                if (collection == Collection.NODES) {
                    // update cache
View Full Code Here

    }
    DBObject criteria = query.toQueryObject(query.getObjectMapper());
    if (this.atomic) {
      criteria.put("$atomic", 1);
    }
    WriteResult result = collection.update(
      criteria, toModifierObject(),
      upsert, multi, concern, dbEncoder);
    if (result.getError()!=null) {
      throw new MongoException(result.getError());
    }
View Full Code Here

        update = removeAssociationRowKey( assocSnapshot, rowKey, associationField );
        break;
      }

      if ( update != null ) {
        collection.update( query, update, true, false, writeConcern );
      }
    }
  }

  @Override
View Full Code Here

    protected void saveModelChanges(String objectID, ModelChanges<T> modelChanges) {
        Assert.isInstanceOf(MongoModelChanges.class, modelChanges);
        MongoModelChanges<T> mongoModelChanges = (MongoModelChanges<T>) modelChanges;

        DBCollection primaryCollection = getPrimaryCollection();
        primaryCollection.update(new QueryMongoDBObject().forID(objectID), mongoModelChanges.toDBObject(), false, false, WriteConcern.SAFE);
    }

    @Timed
    @ExceptionMetered
    public void delete(T object) {
View Full Code Here

    List<?> rows = getAssociationRows( association, key );

    DBObject update = new BasicDBObject( "$set", new BasicDBObject( associationField, rows ) );

    collection.update( query, update, true, false, writeConcern );
  }

  @Override
  public void removeAssociation(AssociationKey key, AssociationContext associationContext) {
    AssociationStorageStrategy storageStrategy = getAssociationStorageStrategy( key, associationContext );
View Full Code Here

        update = removeAssociationRowKey( assocSnapshot, rowKey, associationField );
        break;
      }

      if ( update != null ) {
        collection.update( query, update, true, false );
      }
    }
  }

  @Override
View Full Code Here

                        }
                    }
                }
                scores.remove(lowScore);
                obj.put("scores", scores);
                collection.update( new BasicDBObject("_id",obj.get("_id")), obj, true, false );
            }
        } finally {
            cursor.close();
        }
    }
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.