我对spring datarest有一个问题,对于下面定义的一个投影,当farmer id与farmer对象相同时,它只返回id,而不是返回farmer对象。对于具有id的farmer的第一个示例,返回object,所有其他示例都是only id。
@Projection(name = "customCocoonlot", types = { CocoonLot.class })
public interface CustomCocoonlot {
@Value("#{target}")
public CocoonLot getCocoonLot();
@Value("#{target.getFarmerPayout()}")
public FarmerPayout getFarmerPayout();
@Value("#{target.getFarmer()}")
public Farmer getFarmer();
}
下面是一个示例数据:
"cocoonlot": [
{
"cocoonLot": {
"id": 19,
"grade": 6.0,
"lotWeight": 1.0,
"pricePerKg": 360.0
},
"farmer": {
"id": 10,
"phone": "9999999999",
"name": "Test Farmer",
}
},
{
"cocoonLot": {
"id": 20,
"grade": 6.0,
"lotWeight": 2.0,
"pricePerKg": 360.0
},
"farmer": 10 --> ISSUE HERE
}
]
但预期结果如下:
"cocoonlot": [
{
"cocoonLot": {
"id": 19,
"grade": 6.0,
"lotWeight": 1.0,
"pricePerKg": 360.0
},
"farmer": {
"id": 10,
"phone": "9999999999",
"name": "Test Farmer",
}
},
{
"cocoonLot": {
"id": 20,
"grade": 6.0,
"lotWeight": 2.0,
"pricePerKg": 360.0
},
"farmer": {
"id": 10,
"phone": "9999999999",
"name": "Test Farmer",
}
}
]
暂无答案!
目前还没有任何答案,快来回答吧!