を。
public static String[] getNullPropertyNames(Object source) {
final BeanWrapper src = new BeanWrapperImpl(source);
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
Set<String> emptyNames = new HashSet<String>();
for (java.beans.PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName());
if (srcValue == null) emptyNames.add(pd.getName());
}
String[] result = new String[emptyNames.size()];
return emptyNames.toArray(result);
}
public static void copyProperties(Object src, Object target) {
BeanUtils.copyProperties(src, target, getNullPropertyNames(src));
}
次に、この
public Publisher update(@Named("id") Long id, Publisher publisher) throws Exception {
checkExists(id);
Publisher destination = get(id);
copyProperties(publisher, destination);
return insert(destination);
}
NOTEのようなあなたのアップデートを使用します。このメソッドはnullを、リストのプロパティをオーバーライドしません。
thing.setWhatever()については、更新するフィールドを知っておく必要がありますが、setfirstName()またはsetMobileNumber()を設定することができます。 – siva