杰克逊已经有了POJO的身份证 [英] Jackson Already had POJO for id
问题描述
我遇到错误:我的服务中已经有id
的POJO。
I'm having trouble with the error: Already had POJO for id
in my service.
I有一个方法,需要一个实体列表,我正在传递对象。
I have a method that expects a list of entities, and I'm passing objects to it.
我的实体类定义为:
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@asset_id", scope=Asset.class)
public class Asset extends BaseEntity implements Serializable {
当我发送对象时,我发送的所有属性都已填写但没有 @asset_id
已定义。
When I send the objects, I am sending them with all properties filled out but with no @asset_id
defined.
当我从数据库中获取项目列表时,它是这样的:
When I get the list of items out of the db, it is like this:
[{@ actor_id:1,id:1,name:Test}]
当我寄回时,我发送
[{id: 1,名称:测试}]
为什么我收到此错误?如果我离开 @actor_id
,我也会得到错误。我无法理解。
Why am I getting this error? If I leave the @actor_id
in I get the error too. I can't figure it out.
推荐答案
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property =@ id ,scope = Asset.class)
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class,property="@id", scope=Asset.class)
这可能会解决您的问题。
This might solve your problem.
这篇关于杰克逊已经有了POJO的身份证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!