小编Bot*_*eth的帖子

作为实体的密封类

我对密封课程有疑问。如果我从 docker 运行我的应用程序,它工作得很好,但如果我在 IntelliJ 中执行相同的操作,我会遇到以下异常:

java.lang.IncompatibleClassChangeError: class com.nemethlegtechnika.products.model.Attribute$HibernateProxy$D0WxdNVz cannot inherit from sealed class com.nemethlegtechnika.products.model.Attribute

如果我使用抽象类而不是密封类,那么在 IntelliJ 和 Docker 中都不会出现错误。你们能帮我找到问题的根源吗?

提前致谢,祝您有美好的一天!:)

课程:
package com.nemethlegtechnika.products.model

import jakarta.persistence.*
import org.hibernate.annotations.DiscriminatorFormula

@Entity
@Table(name = "attribute")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorFormula("case when stringValues is not null then 'string' else 'boolean' end")
sealed class Attribute : BaseEntity() {

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = "product_id")
    val product: Product? = null

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @JoinColumn(name = "group_id")
    val group: Group? = null

    abstract …
Run Code Online (Sandbox Code Playgroud)

spring hibernate kotlin docker sealed-class

5
推荐指数
1
解决办法
993
查看次数

标签 统计

docker ×1

hibernate ×1

kotlin ×1

sealed-class ×1

spring ×1