首页 文章

Jackson 已经有了POJO的身份证

提问于
浏览
0

我遇到了错误: Already had POJO for id 在我的服务中 .

我有一个方法,需要一个实体列表,我正在传递对象 .

我的实体类定义为:

@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@asset_id", scope=Asset.class)
public class Asset extends BaseEntity implements Serializable {

当我发送对象时,我发送的所有属性都已填写但没有定义 @asset_id .

当我从数据库中获取项目列表时,它是这样的:

[{ "@actor_id": 1, "id": 1, "name": "Test" }]

当我发回它时,我发送它

[{ "id": 1, "name": "Test" }]

为什么我收到此错误?如果我离开 @actor_id ,我也会得到错误 . 我无法弄明白 .

1 回答

  • 0

    @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property =“@ id”,scope = Asset.class)

    这可能会解决您的问题 .

相关问题