Guest User

Untitled

a guest
Nov 13th, 2019
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void bulkUpdate(List<Map<String, Object>> users) {
  2.         BulkOperations bulkOperations = mongoTemplate.bulkOps(BulkOperations.BulkMode.UNORDERED, getCollectionName());
  3.         for (Map<String, Object> user : users) {
  4.             Query query = new Query(Criteria.where("_id").is((String) user.get("_id")));
  5.             bulkOperations.replaceOne(query, user, FindAndReplaceOptions.options().upsert());
  6.         }
  7.         bulkOperations.execute();
  8.     }
  9.  
  10. //pom.xml
  11. <parent>
  12.         <groupId>org.springframework.boot</groupId>
  13.         <artifactId>spring-boot-starter-parent</artifactId>
  14.         <version>2.1.5.RELEASE</version>
  15.     </parent>
  16.  
  17.     <dependencyManagement>
  18.         <dependencies>
  19.             <dependency>
  20.                 <groupId>org.springframework.data</groupId>
  21.                 <artifactId>spring-data-releasetrain</artifactId>
  22.                 <version>Moore-RELEASE</version>
  23.                 <scope>import</scope>
  24.                 <type>pom</type>
  25.             </dependency>
  26.         </dependencies>
  27.     </dependencyManagement>
RAW Paste Data