Hi Vashitva,
Please see an example of Bulk Operations in the MongoDB Java Driver QuickTour page. For example, you can do ordered bulk write to insert, update and delete as below:
List<WriteModel<Document>> writes = new ArrayList<WriteModel<Document>>();
writes.add(new InsertOneModel<Document>(new Document("_id", 6)));
writes.add(new UpdateOneModel<Document>(new Document("_id", 1), new Document("$set", new Document("x", 2))));
writes.add(new DeleteOneModel<Document>(new Document("_id", 2)));
collection.bulkWrite(writes);
The snippet code above is for MongoDB v3.2 and MongoDB Java Driver v3.2.x.
If you are facing a specific issue using bulk operations, could you post relevant details of:
See also BulkWriteOperation class.
Regards,
Wan.