使用除 SINGLE_TABLE 之外的任何其他 Hibernate 继承策略时 JVM 崩溃
好吧,这可能不太可能,但还是这样吧。
在 Java (JRE 1.6.0_26-b03) 中,我有两个类,SuperControl
及其子类 SubControl
。它们都需要是持久对象,我正在使用 Hibernate Annotations 来实现这一点。我大约有 210 个类被正确保留。但有一个不是。
我的问题是 SubControl
拒绝以 SINGLE_TABLE
之外的任何方式继承。当我说“拒绝”时,我的意思是整个 JRE 崩溃。
这有点问题,因为我真的更喜欢 SuperControl
成为 SubControl
的映射超类。 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,完成了几次清理和构建,甚至重新启动了我的机器,但问题仍然存在。
有什么想法吗?我已经为此工作了几个小时但一无所获。
谢谢!
Ok, this is probably a longshot but here goes.
In Java (JRE 1.6.0_26-b03) I have two classes, SuperControl
and its subclass SubControl
. They both need to be persistent objects and I'm using Hibernate Annotations to achieve this. I have approximately 210 classes that are being persisted correctly. Except one isn't.
My problem is that SubControl
refuses to inherit in any way besides SINGLE_TABLE
. When I say "refuses", I mean that the entire JRE crashes.
This is a bit problematic because I'd really prefer SuperControl
to be a mapped superclass of SubControl
. SuperControl
can also be a persistent entity in its own right. The strange thing is that I have an exactly parallel hierarchy in my code elsewhere that works correctly.
This is what I want:
@Entity
@MappedSuperclass
public class SuperControl extends ItsSuperClass {
// ...
}
@Entity
public class SubControl extends SuperControl {
// ...
}
but it bombs out with the error
#
# 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
Without supplying any inheritance hint, Hibernate defaults to SINGLE_TABLE
(which I can tell thanks to the creation of a DTYPE
column). I can explicitly specify this without the JVM crashing.
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class SuperControl extends ItsSuperClass {
// ...
}
@Entity
public class SubControl extends SuperControl {
// ...
}
The worst part is that if I remove the SubControl
class ENTIRELY, or even just its mapping in the hibernate.cfg.xml file, the JVM still crashes. This leads me to believe that there's some kind of hidden linkage between SuperControl
and SubControl
. Maybe something cached in Eclipse or the like. I've restarted Eclipse, done several clean-and-builds, and even restarted my machine, and the problem's still there.
Any ideas? I've been working on this for hours and have gotten nowhere.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来像 bug 7042153,又名 2210012 于 5 月初报告。
请注意一位用户提供的解决方法:使用“-server”JVM 选项为他们修复了该问题。
This looks like a bug 7042153, aka 2210012 reported in early May.
Note the workaround offered by one user: using the "-server" JVM option fixed it for them.
尝试 Java 1.6.0_20,并检查是否有效。您发现了 JVM 错误,并且返回 6 个次要版本可能足以使其运行。
您很幸运,这个错误是可重现的,因此创建一个最小的测试用例并将其发布到 Oracle 错误数据库。
Try Java 1.6.0_20, and check if that works. You have found a JVM bug, and going back 6 minor versions might be enought to get this running.
You are lucky in the way that this bug is reproducable, so create a minimal testcase and post it to the Oracle bug database.