Examples of findAndModify()


Examples of com.mongodb.DBCollection.findAndModify()

          DBObject dboUpdate = null;
          if (_diagnosticMode) {
            dboUpdate = col.findOne(query,fields);
          }
          else {
            dboUpdate = col.findAndModify(query,fields,new BasicDBObject(),false,updateOp,false,true)
              // (can use findAndModify because specify index, ie the shard key)
              // (returns event before the changes above, update the feature object below)
              // (also atomically creates the object if it doesn't exist so is "distributed-safe")
          }
          if ( ( dboUpdate != null ) && !dboUpdate.keySet().isEmpty() )
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

            DBObject dboUpdate = null;
            if (_diagnosticMode) {
              dboUpdate = col.findOne(query,fields);
            }
            else {
              dboUpdate = col.findAndModify(query, fields, new BasicDBObject(), false, updateOp, false, true);
                // (can use findAndModify because specify index, ie the shard key)
                // (returns entity before the changes above, update the feature object below)
                // (also atomically creates the object if it doesn't exist so is "distributed-safe")
            }
            if ( ( dboUpdate != null ) && !dboUpdate.keySet().isEmpty() ) // (feature already exists)
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

        EntityCache cache = createCache();

        if (log.isTraceEnabled())
            log.trace("Executing findAndModify(" + dbColl.getName() + ") with delete ...");

        DBObject result = dbColl.findAndModify(qi.getQueryObject(), qi.getFieldsObject(), qi.getSortObject(), true, null, false, false);

        if (result != null) {
            T entity = (T) mapr.fromDBObject(qi.getEntityClass(), result, cache);
            return entity;
        }
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

        if (log.isTraceEnabled())
            log.info("Executing findAndModify(" + dbColl.getName() + ") with update ");
        DBObject res = null;
        try {
            res = dbColl.findAndModify(query.getQueryObject(),
                    query.getFieldsObject(),
                    query.getSortObject(),
                    false,
                    ((UpdateOpsImpl<T>) ops).getOps(), !oldVersion,
                    createIfMissing);
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

                query.and(Document.MOD_COUNT).is(modCount);
                DBObject fields = new BasicDBObject();
                // return _id only
                fields.put("_id", 1);

                DBObject oldNode = dbCollection.findAndModify(query.get(), fields,
                        null /*sort*/, false /*remove*/, update, false /*returnNew*/,
                        false /*upsert*/);
                if (oldNode != null) {
                    // success, update cached document
                    applyToCache(collection, cachedDoc, updateOp);
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

            }

            // conditional update failed or not possible
            // perform operation and get complete document
            QueryBuilder query = createQueryForUpdate(updateOp, checkConditions);
            DBObject oldNode = dbCollection.findAndModify(query.get(), null,
                    null /*sort*/, false /*remove*/, update, false /*returnNew*/,
                    upsert);
            if (checkConditions && oldNode == null) {
                return null;
            }
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

                query.and(Document.MOD_COUNT).is(modCount);
                DBObject fields = new BasicDBObject();
                // return _id only
                fields.put("_id", 1);

                DBObject oldNode = dbCollection.findAndModify(query.get(), fields,
                        null /*sort*/, false /*remove*/, update, false /*returnNew*/,
                        false /*upsert*/);
                if (oldNode != null) {
                    // success, update cached document
                    applyToCache(collection, cachedDoc, updateOp);
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

            }

            // conditional update failed or not possible
            // perform operation and get complete document
            QueryBuilder query = createQueryForUpdate(updateOp, checkConditions);
            DBObject oldNode = dbCollection.findAndModify(query.get(), null,
                    null /*sort*/, false /*remove*/, update, false /*returnNew*/,
                    upsert);
            if (checkConditions && oldNode == null) {
                return null;
            }
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

    BasicDBObject update = new BasicDBObject();
    //FIXME should "value" be hardcoded?
    //FIXME how to set the initialValue if the document is not present? It seems the inc value is used as initial new value
    Integer incrementObject = increment == 1 ? ONE : Integer.valueOf( increment );
    this.addSubQuery( "$inc", update, SEQUENCE_VALUE, incrementObject );
    DBObject result = currentCollection.findAndModify( query, null, null, false, update, false, true );
    Object idFromDB;
    idFromDB = result == null ? null : result.get( SEQUENCE_VALUE );
    if ( idFromDB == null ) {
      //not inserted yet so we need to add initial value to increment to have the right next value in the DB
      //FIXME that means there is a small hole as when there was not value in the DB, we do add initial value in a non atomic way
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

    if ( idFromDB == null ) {
      //not inserted yet so we need to add initial value to increment to have the right next value in the DB
      //FIXME that means there is a small hole as when there was not value in the DB, we do add initial value in a non atomic way
      BasicDBObject updateForInitial = new BasicDBObject();
      this.addSubQuery( "$inc", updateForInitial, SEQUENCE_VALUE, initialValue );
      currentCollection.findAndModify( query, null, null, false, updateForInitial, false, true );
      idFromDB = initialValue; //first time we ask this value
    }
    else {
      idFromDB = result.get( SEQUENCE_VALUE );
    }
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.