I have an abstract class
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type", visible = true, include = As.EXISTING_PROPERTY)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@JsonSubTypes({
@Type(value = B.class, name = "B"),
...
})
public abstract class A {
...
}
and one of subclasses
@DiscriminatorValue("B")
@JsonTypeName("B")
public class B extends A {
...
}
When I want to create one entity I need to specify "_type" property. Which is perfectly good. But when I want a list of A-s, I can't get property "_type" specified in JSON response.
I've tried multiple solutions but cannot find the right way to do it.
I've tried to add "_type" property with transactional, tried to add "include = JsonTypeInfo.As.PROPERTY"
. But still nothing.
Of course for everything I have only one controller for class A.
Can anyone tell me how to get "_type" in get response and other responses?
tnx