Could not read JSON: Already had POJO for id (java.lang.Integer) [1] (through reference chain: eu.cobiz.web.domain.Site[“operators”]->eu.yavix.web.domain.Account[“image”]->eu.cobiz.web.domain.Image[“@Image”]);nested exception is com.fasterxml.jackson.databind.JsonMappingException: Already had POJO for id (java.lang.Integer) [1] (through reference chain: eu.yavix.web.domain.Site[“operators”]->eu.cobiz.web.domain.Account[“image”]->eu.cobiz.web.domain.Image[“@Image”])
我试图反序列化的JSON看起来像:
{ "@Site": 1,"siteId": 1,"name": "0","address": { "@Address": 2,"addressId": 4,"number": "22" },"operators": [ { "accountId": 1,"email": "user982701361@yavix.eu","image": { "@Image": 1,"imageId": 1,"uri": "http://icons.iconarchive.com/icons/deleket/purple-monsters/128/Alien-awake-icon.png" } },{ "accountId": 2,"email": "user174967957@yavix.eu","image": { "@Image": 2,"imageId": 2,"uri": "http://icons.iconarchive.com/icons/deleket/purple-monsters/128/Alien-awake-icon.png" } } ] }
我的域对象被注释
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property = "@Image")
问题出现在@Id注释,因为如果我删除注释问题消失(就像我做了帐号),但是我的理解是,新功能对于循环依赖是有用的,在其他情况下对我来说是有用的.两个图像之间不应该有冲突,因为它们是不同的对象.
有谁有一个想法如何解决或什么问题?
解决方法
从注释类型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.
例如@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property =“@ id”,scope = Account.class)