Package com.mongodb

Examples of com.mongodb.DBCollection.update()


                .get();
        u = new BasicDBObject();
        u.put("$set",
                new BasicDBObject(CommitMongo.KEY_BASE_REVISION_ID, MongoUtil
                        .toMongoRepresentation(firstRevisionId)));
        commitCollection.update(q, u);

        FetchNodesByPathAndDepthQuery query = new FetchNodesByPathAndDepthQuery(mongoConnection, "/", thirdRevisionId,
                -1);
        List<NodeMongo> result = query.execute();
        List<Node> actuals = NodeMongo.toNode(result);
View Full Code Here


                        DBObject bsonState = (DBObject) JSON.parse( toString() );

                        BasicDBObject entity = new BasicDBObject();
                        entity.put( IDENTITY_COLUMN, ref.identity() );
                        entity.put( STATE_COLUMN, bsonState );
                        entities.update( byIdentity( ref ), entity, false, false, writeConcern );
                    }
                };
            }

            @Override
View Full Code Here

        BasicDBObject key = new BasicDBObject("id","1234");
        BasicDBObject sets = new BasicDBObject("name","value");
        BasicDBObject upsert=new BasicDBObject("$set",sets);
       
        WriteResult result =coll.update(key,upsert,true,false);
       
        System.err.println(result.getLastError());
       
       
        while (coll.count()>0)
View Full Code Here

            doc.runCallbacks(Callbacks.Callback.before_update);
            //we cannot call doc.collection().remove() directly,because of the dam inheritance of static methods in java
            if (doc.id() == null) return false;
            DBCollection collection = (DBCollection) ReflectHelper.staticMethod(doc.getClass(), "collection");
            DBObject query = new BasicDBObject("_id", doc.id());
            collection.update(query,new BasicDBObject( doc.attributes()));
            doc.runCallbacks(Callbacks.Callback.after_update);
        }

        return true;
    }
View Full Code Here

    public void testUpdate() throws Exception {
        DBCollection collection = readOnlyClient.getDB("testdb").getCollection("testcollection");
        BasicDBObject object = new BasicDBObject("_id", 1);
        BasicDBObject newObject = new BasicDBObject("_id", 1);
        try {
            collection.update(object, newObject);
            fail("MongoException expected");
        } catch (MongoException e) {
            // okay
        }
    }
View Full Code Here

        DBCollection collection = readOnlyClient.getDB("testdb").getCollection("testcollection");

        BasicDBObject object = new BasicDBObject("_id", 1);
        BasicDBObject newObject = new BasicDBObject("_id", 1);
        try {
            collection.update(object, newObject, true, false);
            fail("MongoException expected");
        } catch (MongoException e) {
            // okay
        }
    }
View Full Code Here

    List<DBObject> 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

    List<DBObject> 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

            baseFields.put(AssociationFeaturePojo.db_sync_doccount_, evtFeature.getDb_sync_doccount());
            baseFields.put(AssociationFeaturePojo.db_sync_time_, evtFeature.getDb_sync_time());                           

            if (!_diagnosticMode) {
              // Store the object
              col.update(query, new BasicDBObject(MongoDbManager.set_, baseFields));
            }
            else {
              System.out.println("EventAggregationUtils.updateEventFeatures, not found: " + query.toString() + " / " + baseFields.toString() + "/ orig_update= " + updateOp.toString());
            }
            evtFeature.setDb_sync_time(null); // (ensures that index re-sync will occur)           
View Full Code Here

        else {
          System.out.println("(WOULD NOT RUN) EventAggregationUtils.synchronizeEventFeature, featureDB: " + query.toString() + " / " + update.toString());       
        }
      }
      else {
        eventFeatureDb.update(query, update, false, true);
      }
    }

    if (_diagnosticMode) {
      System.out.println("EventAggregationUtils.synchronizeEventFeature, synchronize: " + new StringBuffer(eventFeature.getIndex()).append(':').append(communityId).toString() + " = " +
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.