You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Morphia时无论是否设置默认鉴别器均无法读取多态类型的问题

使用Morphia时无论是否设置默认鉴别器均无法读取多态类型的问题

各位好,我最近在Morphia里处理多态实体的时候碰到了个头疼的问题——不管我有没有配置默认鉴别器,都没办法正确读取对应的多态类型数据。先给大伙看看我的实体结构:

父类:Interceptor.java

@Entity(discriminatorKey = "type")
public abstract class Interceptor {

    @Id
    protected String id;
    protected String type;

    public Interceptor(String type) {
        this.type = type;
    }

    // getters and setters omitted..
}

然后是它的子类ScriptInterceptor.java,我还没写完完整代码,先贴出已有的注解部分:

@Entity(discriminator = "script", discriminatorK

现在的问题是,当我从数据库查询Interceptor类型的数据时,Morphia总是没法自动识别并映射到对应的子类实例,试了设置默认鉴别器、不设置默认鉴别器都不管用。有没有大佬遇到过类似的情况,或者能给我点排查的思路呀?

备注:内容来源于stack exchange,提问作者Matheus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 16:09:39