[英]How to update only attributes that have changed - Spring MVC mongoDB
I'm using Spring Data MongoDB and Spring Data Rest to create a REST API which allows GET, POST, PUT and DELETE operations on my MongoDB database and it's all working fine except for the update operations (PUT). 僅當我在請求正文中發送完整的 object 否則變量未在請求中發送它是 null 時才有效。有人可以指導我解決這個問題。
@PutMapping("/update/{id}")
public void update(@Valid @RequestBody Facture facture, @PathVariable("id") String id){
Optional<Facture> factureData = factureRepository.findById(id);
facture.setId_facture(id);
this.factureRepository.save(facture);
}
你可以試試像javer這樣的object比較庫
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.