简体   繁体   English

Orika-如何为未使用的属性禁用映射?

[英]Orika - How to disable Mapping for unused Attributes?

I have two classes: 我有两节课:

public class Source {
    String a;
}

public class Target {
    String a, b;
}

When I map from source to target the attribute a is perfectly mapped. 当我从源映射到目标时,属性a被完美映射。 But the attribut b , which is not existing in the source, is always set to null. 但是源中不存在的属性b始终设置为null。 Is there a way to avoid this bahaviour? 有办法避免这种行为吗?

When new object is instantiated all attributes are set to null. 实例化新对象时,所有属性均设置为null。 Orika will set only used attributes the others will keep their null value. Orika将仅设置使用的属性,其他将保留其空值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM