It looks these two methods both save a BasicDbObject to a collection instance.What is the difference between these two methods?
com.mongodb.DBCollection.Insert()
com.mongodb.DBCollection.Save()
It looks these two methods both save a BasicDbObject to a collection instance.What is
Share
Save can only save one object at a time. If _id is provided and it already exists, the new document will overwrite the previously existing one. If it doesn’t exist, it will do an insert.
Insert can take a single object or an ArrayList of objects and do a “bulk insert” of them.
If you give an existing _id to an insert it will cause a duplicate Id exception.