Examples of findAndModify()


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 how to set the initialValue if the document is not present? It seems the inc value is used as initial new value
    Integer incrementObject = Integer.valueOf( request.getIncrement() );
    this.addSubQuery( "$inc", update, valueColumnName, incrementObject );
    DBObject result = currentCollection.findAndModify( query, null, null, false, update, false, true );
    Object idFromDB;
    idFromDB = result == null ? null : result.get( valueColumnName );
    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, valueColumnName, request.getInitialValue() );
      currentCollection.findAndModify( query, null, null, false, updateForInitial, false, true );
      idFromDB = request.getInitialValue(); //first time we ask this value
    }
    else {
      idFromDB = result.get( valueColumnName );
    }
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

        DBObject query = new BasicDBObject();
        DBObject inc = new BasicDBObject(HeadMongo.KEY_NEXT_REVISION_ID, Long.valueOf(1));
        DBObject update = new BasicDBObject("$inc", inc);
        DBCollection headCollection = mongoConnection.getHeadCollection();

        DBObject dbObject = headCollection.findAndModify(query, null, null, false, update, true, false);
        // Not sure why but sometimes dbObject is null. Simply retry for now.
        while (dbObject == null) {
            dbObject = headCollection.findAndModify(query, null, null, false, update, true, false);
        }
        return HeadMongo.fromDBObject(dbObject);
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

        DBCollection headCollection = mongoConnection.getHeadCollection();

        DBObject dbObject = headCollection.findAndModify(query, null, null, false, update, true, false);
        // Not sure why but sometimes dbObject is null. Simply retry for now.
        while (dbObject == null) {
            dbObject = headCollection.findAndModify(query, null, null, false, update, true, false);
        }
        return HeadMongo.fromDBObject(dbObject);
    }
}
View Full Code Here

Examples of com.mongodb.DBCollection.findAndModify()

        DBCollection headCollection = mongoConnection.getHeadCollection();
        DBObject query = QueryBuilder.start(HeadMongo.KEY_HEAD_REVISION_ID).is(oldHeadRevision).get();
        DBObject update = new BasicDBObject("$set", new BasicDBObject(HeadMongo.KEY_HEAD_REVISION_ID, newHeadRevision));

        DBObject dbObject = headCollection.findAndModify(query, null, null, false, update, true, false);
        if (dbObject != null) {
            headMongo = HeadMongo.fromDBObject(dbObject);
        }

        return headMongo;
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

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.