You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to setup @JsonIdentityInfo/@JsonIdentityReference in order to serialize all references to a given class as Object Id (and deserialize them later using a custom ObjectIdResolver to retrieve the proper referenced instance)
I use @JsonIdentityReference(alwaysAsId=true) in order to enforce exporting the object id in all cases.
It does not work as expected when I define the annotation only on the class (but it works fine when I set it directly on the property). I would rather not have to define it on every property as I will probably miss some...
From what I see in BeanSerializerBase, the alwaysAsId is reset when not ObjectIdInfo is found on the accessor:
ObjectIdInfoobjectIdInfo = intr.findObjectIdInfo(accessor);
if (objectIdInfo == null) {
// no ObjectId override, but maybe ObjectIdRef?if (oiw != null) {
objectIdInfo = intr.findObjectReferenceInfo(accessor,
newObjectIdInfo(NAME_FOR_OBJECT_REF, null, null, null));
oiw = _objectIdWriter.withAlwaysAsId(objectIdInfo.getAlwaysAsId());
Shouldn't it be kept to the current value when no override is found ?
I tried to set it back in the default ObjectIdInfo created with NAME_FOR_OBJECT_REF but I am not sure if this is the right way to fix this.
Yes, fixed. Not sure if this is the best fix either (handling of defaulting done in a bit odd way), but handles this case, does not break any other tests.
I am trying to setup @JsonIdentityInfo/@JsonIdentityReference in order to serialize all references to a given class as Object Id (and deserialize them later using a custom ObjectIdResolver to retrieve the proper referenced instance)
I use @JsonIdentityReference(alwaysAsId=true) in order to enforce exporting the object id in all cases.
It does not work as expected when I define the annotation only on the class (but it works fine when I set it directly on the property). I would rather not have to define it on every property as I will probably miss some...
From what I see in BeanSerializerBase, the alwaysAsId is reset when not ObjectIdInfo is found on the accessor:
Shouldn't it be kept to the current value when no override is found ?
I tried to set it back in the default ObjectIdInfo created with NAME_FOR_OBJECT_REF but I am not sure if this is the right way to fix this.
Here is test I added in TestObjectIdSerialization for this case:
The text was updated successfully, but these errors were encountered: