我有两个JPA实体(患者和诊所)与OneToMany ManyToOne关系。我想以JSON格式返回数据(目前使用org.apache.cxf.jaxrs.provider.JSONProvider
)。以下是患者信息及其相关诊所。但是,它会返回诊所的所有字段。我怎样才能为诊所返回主键/ id(@Id)?
{
"Patient": {
"age": 0,
"clinic": {
"address": "long address here",
"otherKeys": "other values",
"id": 5
},
"ic": "010101",
"id": 12,
"name": "Patient 01"
}
}