我有一个像下面的DTO
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* Simple DTO for ServiceContract.
*/
public class ServiceContractDTO {
public Long id;
public String name;
public String description;
public String type;
public Long contractStart;
public Long contractEnd;
public Boolean isrepeated;
public Boolean autoApproved;
public Boolean staffAutoApproved;
public Long createdts;
public Long updatedts;
public String createdby;
public String status;
public HospitalDTO hospital;
public HospitalUnitDTO unit;
public StaffDTO preferredStaff;
public SpecialtyDTO specialty;
public SkillMasterDTO skill;
public ServiceLocationDTO serviceLocation;
public ServiceScheduleDTO serviceSchedule;
@JsonIgnore
public boolean isIdSet() {
return id != null;
}
}
现在,如果更新,我只能从UI获取空字段。如何仅设置这些并更新对象。我不想为所有这些属性检查null并设置它们。有更好的方法吗?
我会得到一个喜欢
的json{
"id": 13,
"name": "test contract"
}
任何代码示例都有帮助