List of usage examples for com.mongodb DBCollection insert
public WriteResult insert(final List<? extends DBObject> documents, final InsertOptions insertOptions)
Insert documents into a collection.
From source file:rtpmt.models.Temperature.java
public void save() { DBCollection packageColl = db.getCollection(DBConstants.TEMPERATURE_COLLECTION); /*//from w w w .ja va2 s. com BasicDBObject query = new BasicDBObject(); query.put(DBConstants.SENSOR_ID, this.get(DBConstants.SENSOR_ID)); query.put(DBConstants.TRUCK_ID, this.get(DBConstants.TRUCK_ID)); query.put(DBConstants.PACKAGE_ID,this.get(DBConstants.PACKAGE_ID)); query.put(DBConstants.TIMESTAMP, this.get(DBConstants.TIMESTAMP)); BasicDBObject set = new BasicDBObject(); set.put("$set", this); packageColl.update(query, set, true, false); */ packageColl.insert(this, WriteConcern.ACKNOWLEDGED); }