我想将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"
}
]