Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Description{
- private String code;
- public String getCode() {
- return code;
- }
- public void setCode(String code) {
- this.code = code;
- }
- }
- BulkOperations bulkOperations = mongoTemplate.bulkOps(BulkOperations.BulkMode.UNORDERED, getCollectionName());
- Description d = new Description();
- d.setCode("no");
- Query query = new Query(Criteria.where("code").is(d.getCode()));
- Document doc = new Document(); // org.bson.Document
- mongoTemplate.getConverter().write(d, doc);
- Update update = Update.fromDocument(doc);
- System.out.println(update.toString());
- bulkOperations.upsert(query, update);
- bulkOperations.execute();
- }
Add Comment
Please, Sign In to add comment