好吧,这可能是一个远景,但现在就开始吧。
在 Java (JRE 1.6.0_26-b03) 中,我有两个类,SuperControl
及其子类 SubControl
。它们都需要是持久对象,我正在使用 Hibernate Annotations 来实现这一点。我有大约 210 个正确保存的类。除了一个不是。
我的问题是 SubControl
拒绝以除 SINGLE_TABLE
之外的任何方式继承。当我说“拒绝”时,我的意思是整个 JRE 崩溃。
这有点问题,因为我真的更喜欢 SuperControl
是 SubControl
的映射父类(super class)。 SuperControl
本身也可以是一个持久实体。奇怪的是,我在其他地方的代码中有一个完全平行的层次结构,可以正常工作。
这就是我想要的:
@Entity
@MappedSuperclass
public class SuperControl extends ItsSuperClass {
// ...
}
@Entity
public class SubControl extends SuperControl {
// ...
}
但它因错误而爆炸
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (c1_Optimizer.cpp:271), pid=5456, tid=1260
# guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Client VM (20.1-b02 mixed mode, sharing windows-x86 )
# An error report file with more information is saved as:
# C:\eclipse\hs_err_pid5456.log
在不提供任何继承提示的情况下,Hibernate 默认为 SINGLE_TABLE
(这要归功于 DTYPE
列的创建)。我可以在 JVM 不崩溃的情况下明确指定它。
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class SuperControl extends ItsSuperClass {
// ...
}
@Entity
public class SubControl extends SuperControl {
// ...
}
最糟糕的是,如果我完全删除 SubControl
类,或者甚至只是删除它在 hibernate.cfg.xml 文件中的映射,JVM 仍然 崩溃。这使我相信 SuperControl
和 SubControl
之间存在某种隐藏的联系。也许是缓存在 Eclipse 之类的东西。我已经重新启动 Eclipse,完成了几次清理和构建,甚至重新启动了我的机器,但问题仍然存在。
有什么想法吗?我已经为此工作了几个小时,但一无所获。
谢谢!
最佳答案
这看起来像一个 bug 7042153 , 又名 2210012五月初报道。
请注意一位用户提供的解决方法:使用“-server”JVM 选项为他们修复了它。
关于java - 使用除 SINGLE_TABLE 之外的任何其他 Hibernate 继承策略时 JVM 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6553428/