0
Null值在我的Java項目中,我使用org.dozer.BeanMapper一個複雜的源對象合併到與同類型目標對象:DozerBeanMapper:忽略來自源
sourceObject.valueA = null
sourceObject.valueB = B1
sourceObject.valueC = C1
destinationObject.valueA = A2
destinationObject.valueB = null
destinationObject.valueC = C2
beanMerger.map(sourceObject, destinationObject);
這將導致該值我destinationObject:
destinationObject.valueA: null
destinationObject.valueB: B1
destinationObject.valueC: C1
我可以配置BeanMapper的方式,它不應該忽略一個空值的字段?我期望的結果應該是:
destinationObject.valueA: A2
destinationObject.valueB: B1
destinationObject.valueC: C1
甚至更好(不要目標對象的觸摸設定值)
destinationObject.valueA: A2
destinationObject.valueB: B1
destinationObject.valueC: C2