将父元素设置为null,映射的子元素为null - Dozer

时间:2016-07-27 16:23:14

标签: java jaxb dozer

我使用JAXB生成了分类。它为一些复杂元素生成了列表。我提供了一个由JaxB生成的类的示例 -

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfLineOfBusiness", propOrder = {
    "lineOfBusiness"
})
public class ArrayOfLineOfBusiness
    implements Serializable
{

    private final static long serialVersionUID = 11082011L;
    protected com.comcast.xml.epc.types.LineOfBusiness[] lineOfBusiness;
}

ArrayOfLineOfBusiness用于Customer类

public class Customer{

@XmlElement(nillable = true)
protected ArrayOfLineOfBusiness linesOfBusiness;

我的模型类有类似于下面的内容:

public class Customer implements Serializable {
private LineOfBusiness[] linesOfBusiness = null;

下面是我的推土机映射

<field>
    <a is-accessible="true">lineOfBusiness.lineOfBusinesses</a>
    <b>lineOfBusiness</b>
</field>

如果我的服务模型中的lineOfBusinesses数组为null,我想设置ArrayOfLineOfBusiness。有办法吗?

1 个答案:

答案 0 :(得分:0)

以下映射似乎解决了这个问题 -

  <mapping map-null="false">