我对密封课程有疑问。如果我从 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)