为什么我的根元素没有显示属性名称

时间:2012-03-21 22:31:23

标签: jpa

我想将jpa查询结果转换为传输对象。当我这样做时,我只得到值而不是键

转移对象

@XmlRootElement(name = "transfer-object")
public class TransferObject {

    private String a;
    private String b;

    public String getA() {
        return a;
    }

    public void setA(String a)}
        this.a = a;
    }

    public String getB() {
        return b;
    }

    public void setB(String b)}
        this.b = b;
    }
}

查询

List<TransferObject> objects = (List<TransferObject>) m_entityManager.createNamedQuery("some named query").getResultList();

实际结果

[
[
"valueA",
"valueB"
],
[
"valueA",
"valueB"
]
]

必填结果

[{
"a":"valueA",
"b":"valueB"
},{
"a":"valueA",
"b":"valueB"
}
]

0 个答案:

没有答案