3

私は持っていList<SelectConditionHeaderModel>ます。

このリストをマーシャリングすると、エラーが発生します:

javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.internal.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML

私の抽象的な親クラス。

@XmlRootElement
@XmlSeeAlso({ SelectConditionHeaderModel.class,
        SelectConditionModel.class })
public abstract class SelectConditionParentModel {

    @XmlInverseReference(mappedBy = "conditionList")
    SelectConditionParentModel parent;

    public SelectConditionParentModel getParent() {
        return parent;
    }

    public void setParent(HbaseSelectConditionParentModel parent) {
        this.parent = parent;
    }

}

抽象親を拡張するヘッダー クラス

@XmlRootElement
public class SelectConditionHeaderModel extends
        SelectConditionParentModel {

    List<SelectConditionParentModel> conditionList;

    String header;

    public List<SelectConditionParentModel> getConditionList() {
        return conditionList;
    }

    public void setConditionList(List<SelectConditionParentModel> condition) {
        this.conditionList = condition;
    }

    public String getHeader() {
        return header;
    }

    public void setHeader(String header) {
        this.header = header;
    }

}

抽象親を拡張する条件クラス

@XmlRootElement
public class SelectConditionModel extends SelectConditionParentModel {

    String tableName;


    public String getTableName() {
        return columnFamily;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

}

これで私を助けてください。XMLInverseReference も使用しましたが、機能していないようです。

4

2 に答える 2

0

EclipseLink JAXB (MOXy) を JAXB (JSR-222) プロバイダーとして使用している場合は、@XmlInverseReference拡張機能を利用して双方向の関係をマップできます。

私のブログで完全な例を見つけることができます:

于 2014-08-06T12:33:27.687 に答える
0

@XmlID および @XmlIDREF に基づいて、この構成を使用してみてください。

または @XmlTransient を入れてサブグラフを除外できます。

于 2014-08-06T10:39:01.873 に答える