title: How I Use spring-data-jpa mongoRepository to query and update?
body: <p>Here is my Entity</p>
  
  <pre><code>@Document(collection = "deviceConfig")
  @Data
  @Builder
  public class DbDeviceConfig {
      private ObjectId _id;
  
  //    @Field("id")
  //    @Id
  //    private String id;
  
      private String deviceId;
  
      private String enterpriseId;
  
  
      private Integer state;
  
  
      private String cfgKey;
  
  
      @JsonSerialize
      private String cfgValue;
  
  
      private Long cfgDate;
  
  
      private Long reportDate;
  
  
      private Integer reportCode;
  
  
      private String reportMsg;
  }
  </code></pre>
  
  <p>As you can see I Notes the @Id<br>
  since in my situation，each device will have only one cfgValue of specific cfgKey<br>
  so the enterpriseId and deviceId and cfgKey will keep it unique<br>
  i wrote the mongotemplate update sql        </p>
  
  <pre><code>Query updateQuery = new Query(Criteria.where("enterpriseId").is(enterpriseId)
                      .and("cfgKey").is(batchAddDeviceConfig.getCfgKey())
                      .and("deviceId").is(deviceId));
              Update update = new Update();
              update.set("cfgDate", System.currentTimeMillis());
              update.set("cfgValue", batchAddDeviceConfig.getCfgValue());
              update.set("state", batchAddDeviceConfig.getState());
              dataMongoTemplate.upsert(updateQuery, update, DbDeviceConfig.class, "deviceConfig");
  </code></pre>
  
  <p>but I dont know how to write the Corresponding spring jpa code<br>
  or maybe i should add a Business Id?<br>
  I am really confused,since mongodb already create a ObjectId          </p>
  
  <p>I also search for other people's solution<br>
  it seems i can use this way     </p>
  
  <pre><code>@Modifying
  @Query("UPDATE Space c SET c.owner = :name WHERE c.id = :id")
  Integer setNameForId(@Param("name") String name, @Param("id")
  </code></pre>
  
  <p>but that would be like lots of Parameter<br>
  please help me QAQ    </p>