简体   繁体   English

Junit-org.hibernate.AnnotationException引起的ExceptionInInitializerError

[英]Junit - ExceptionInInitializerError caused by org.hibernate.AnnotationException

I am getting this error when I try to run Junit for my class: 尝试为我的班级运行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

@OneToMany()
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name="ID",referencedColumnName = "ID",insertable=false, updatable=false)
    private List<DataDetails> dataDetails;

Inside the setUp method, I just called initializer method. 在setUp方法中,我只是调用了初始化方法。 Which was not invoked. 没有被调用。 What should I do to run the test successfully? 我应该怎么做才能成功运行测试?

You need to add pojo mapping in your cfg xml file. 您需要在cfg xml文件中添加pojo映射。

<mapping class="xxx.yyy.zzz.bis.details.DataDetails" />

and make sure you specify appropriate qualified name of DataDetails in mapping. 并确保在映射中指定适当的DataDetails合格名称。 because your exception shows two different qualified names. 因为您的例外显示两个不同的限定名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne on - Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on 无法构建Hibernate SessionFactory,由以下原因引起:org.hibernate.AnnotationException: - Unable to build Hibernate SessionFactory, Caused by: org.hibernate.AnnotationException: 获取 org.hibernate.AnnotationException - Getting org.hibernate.AnnotationException java.lang.ExceptionInInitializerError和org.hibernate.AnnotationException:MapdBy引用了未知的目标实体属性: - java.lang.ExceptionInInitializerError and org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: 原因:java.lang.IllegalArgumentException:不是托管类型:&原因:org.hibernate.AnnotationException:未为实体指定标识符: - Caused by: java.lang.IllegalArgumentException: Not a managed type: & Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 在春季使用Hibernate的困难:原因:org.hibernate.AnnotationException:使用@OneToMany或@ManyToMany定位未映射的类: - Difficulties to use Hibernate in a Spring: Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: org.hibernate.AnnotationException:没有为实体指定标识符 - org.hibernate.AnnotationException: No identifier specified for entity org.hibernate.AnnotationException映射错误 - org.hibernate.AnnotationException Mapping Error org.hibernate.AnnotationException: @OneToOne 或 @ManyToOne - org.hibernate.AnnotationException: @OneToOne or @ManyToOne 引起:org.hibernate.AnnotationException:mappedBy 引用了一个未知的目标实体属性 - Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM