I have a DTO like below
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;
}
}
Now I get only not null fields from UI if its an update. How do I set only those and update the object. I dont want to check for null for all these properties and set them..Is there a better approach?
I will get a json like
{
"id": 13,
"name": "test contract"
}
Any code samples will help