gpt4 book ai didi

java - 如何显示特定字段使用ebean关系

转载 作者:行者123 更新时间:2023-12-01 23:08:26 32 4
gpt4 key购买 nike

...是我的代码

    @ManyToOne
@JoinColumn(name = "destination_country_id", referencedColumnName = "id", table = "countries", insertable = false, updatable = false)
public Country country;

...

就是结果

"id": 139,
"country": {
"id": 1,
"iso": "AU",
"name": "Australia",
},
"country_id": 1

...

我希望结果是

"id": 139,
"country": "australia",
"country_id": 1,

...

最佳答案

添加此代码并更改为 var 国家/地区的私有(private)

@Column(name = "name", table = "countries")
public String country_name;

这是我的新代码

@ManyToOne
@JoinColumn(name = "destination_country_id", referencedColumnName = "id", table = "countries", insertable = false, updatable = false)
private Country country;

@Column(name = "name", table = "countries")
public String country_name;

关于java - 如何显示特定字段使用ebean关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58388608/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com