Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Junit-由org.hibernate.AnnotationException引起的Exception InInitializeRerror错误_Java_Hibernate_Junit - Fatal编程技术网

Java Junit-由org.hibernate.AnnotationException引起的Exception InInitializeRerror错误

Java Junit-由org.hibernate.AnnotationException引起的Exception InInitializeRerror错误,java,hibernate,junit,Java,Hibernate,Junit,当我尝试为我的类运行Junit时,出现以下错误: java.lang.ExceptionInInitializerError at xxx.yyy.zzz.dao.dashboard.TestDashboardDAO.setUp(TestDashboardDAO.java:36) at junit.framework.TestCase.runBare(TestCase.java:125) at junit.framework.TestResult$1.protect(

当我尝试为我的类运行Junit时,出现以下错误:

java.lang.ExceptionInInitializerError
    at xxx.yyy.zzz.dao.dashboard.TestDashboardDAO.setUp(TestDashboardDAO.java:36)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: xxx.yyy.zzz.bis.dashboard.details.dataDetails[xxx.yyy.zzz.bis.details.DataDetails]
    at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1168)
    at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:693)
    at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:628)
    at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
    at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1686)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1393)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
    at xxx.yyy.zzz.dao.helper.TestSchema.<init>(TestSchema.java:62)
    ... 14 more
<mapping class="xxx.yyy.zzz.bis.details.DataDetails" />

java.lang.ExceptionInInitializeError
位于xxx.yyy.zzz.dao.dashboard.TestDashboardDAO.setUp(TestDashboardDAO.java:36)
位于junit.framework.TestCase.runBare(TestCase.java:125)
位于junit.framework.TestResult$1.protect(TestResult.java:106)
位于junit.framework.TestResult.runProtected(TestResult.java:124)
运行(TestResult.java:109)
运行(TestCase.java:118)
位于junit.framework.TestSuite.runTest(TestSuite.java:208)
运行(TestSuite.java:203)
位于org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
位于org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
原因:org.hibernate.AnnotationException:使用@OneToMany或@ManyToMany瞄准未映射的类:xxx.yyy.zzz.bis.dashboard.details.dataDetails[xxx.yyy.zzz.bis.details.dataDetails]
位于org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1168)
位于org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:693)
位于org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:628)
位于org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
位于org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1686)
位于org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1393)
位于org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
位于xxx.yyy.zzz.dao.helper.TestSchema。(TestSchema.java:62)
... 14多

@OneToMany()
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name=“ID”,referencedColumnName=“ID”,insertable=false,updateable=false)
私人名单资料详情;

在setUp方法中,我刚刚调用了initializer方法。没有被调用。
如何才能成功运行测试?

您需要在cfg xml文件中添加pojo映射



并确保在映射中指定DataDetails的适当限定名称。因为您的异常显示两个不同的限定名。

您能发布DataDetails.java吗?可能不是数据库模型的一部分
<mapping class="xxx.yyy.zzz.bis.details.DataDetails" />