Blaze Persistence EntityView继承映射

Blaze Persistence EntityView inheritance mapping

我目前正在将 Quarkus 与 Blaze Persistence 结合用于我的微服务。我有以下实体模型:

@Entity
public class Content extends BaseEntity {
    private boolean deleted;
    private boolean published;
}

@Entity
public class WebContent extends Content {
    private String webpage;
}

我已将实体映射到以下 EntityView:

@EntityView(Content.class)
@EntityViewInheritance
@CreatableEntityView
@UpdatableEntityView
public interface ContentUpdateView {
    @IdMapping
    Long getId();
    boolean isPublished();
    void setPublished(boolean published);
}

@EntityView(WebContent.class)
@CreatableEntityView
@UpdatableEntityView
public interface WebContentUpdateView extends ContentUpdateView {
    String getWebpage();
    void setWebpage(String webpage);
}

我的 ContentsResource 中有以下方法:

@POST
public ContentUpdateView save(ContentUpdateView content) {
    return contentsService.save(content);
}

当我调用 post 操作时,我只得到基本的 ContentUpdateView 而不是 WebContentUpdateView。有什么配置要做吗? (对于 Jackson,我在实体上使用 @JsonTypeInfo 和 @JsonSubType 注释来完成此操作)。

谢谢 尤克斯

我使用 Jackson 注释让它工作。这是基础 class:

@EntityView(Content.class)
@EntityViewInheritance
@JsonTypeInfo(
        use = JsonTypeInfo.Id.NAME,
        property = "type")
@JsonSubTypes({
        @JsonSubTypes.Type(value = DescriptiveContentView.class, name = "descriptive"),
        @JsonSubTypes.Type(value = MediaContentView.class, name = "media"),
        @JsonSubTypes.Type(value = WebContentView.class, name = "web")
})
@JsonTypeName("content")
public abstract class ContentView {
    @IdMapping
    public abstract Long getId();
    public abstract boolean isPublished();
}

这是一个子class:

@EntityView(DescriptiveContent.class)
@JsonTypeName("descriptive")
public abstract class DescriptiveContentView extends ContentView {
    public abstract Set<LocalizedParagraphView> getLocalizedParagraphs();
}

我将抽象 classes 用于其他目的,但它也适用于接口。