I've created function that returns the retval variable:
Object retval = foo();
ResponseEntity<List<ProductOrder>> foo() {
//some spring boot logic which returns ResponseEntity of List of ProductOrder
return ....
}
And then I'm using jackson convertValue passing the retval parameter:
jacksonMapper.convertValue(((ResponseEntity)retval).getBody(), new TypeReference<List<ProductOrder>>(){});
I'm getting the following error:
Missing type id when trying to resolve subtype of [simple type, class com.xxx.digital.ms.aaa.bbb.ck.resources.models.ProductOrder]: missing type id property 'link'
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: java.util.ArrayList[0])
I read here and here that I need to register all beforehand all the polymorphism types of ProductOrder (ProductOrder inherits from Link class).
How can I register all the subtypes and polymorphic types beforehand with reflection to Jackson mapper?
Link class is defined as follows but since my code is using reflection is not aware of these annotations
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "link", visible = true )
@JsonSubTypes({
@JsonSubTypes.Type(value = ProductOrder.class, name = "ProductOrder"),
})
public class Link {