JsonMappingException: Already had POJO for id

后端 未结 2 582
星月不相逢
星月不相逢 2020-12-15 18:49

I have an error when trying to work with @JsonIdentityInfo jackson annotation. When I try to deserialize the object I get the following exception:

Could

相关标签:
2条回答
  • 2020-12-15 19:09

    To avoid id conflict try to use ObjectIdGenerators.PropertyGenerator.class or ObjectIdGenerators.UUIDGenerator.class instead of ObjectIdGenerators.IntSequenceGenerator.class

    0 讨论(0)
  • 2020-12-15 19:22

    You should use scope parameter when annotating the ids. Then the de-serializer would make sure the id is unique within the scope.

    From Annotation Type JsonIdentityInfo:

    Scope is used to define applicability of an Object Id: all ids must be unique within their scope; where scope is defined as combination of this value and generator type.

    e.g.

    @JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class,property="@id", scope = Account.class)
    
    0 讨论(0)
提交回复
热议问题