org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.demo.pojo.IdCard

TestStudent.testSchemaExport
testSchemaExport(com.demo.pojo.dxwj.TestStudent)
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.demo.pojo.dxwj.Students.cardId references an unknown entity: com.demo.pojo.dxwj.IdCard
 at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:107)
 at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1580)
 at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1503)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1419)
 at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002)
 at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:130)
 at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
 at com.demo.pojo.dxwj.TestStudent.testSchemaExport(TestStudent.java:28)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at junit.framework.TestCase.runTest(TestCase.java:154)
 at junit.framework.TestCase.runBare(TestCase.java:127)
 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.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
 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)

 

 

原因有二:

(1) 被引用的类的class上没添@Entity注解

(2)没有添sessionFactory的annotatedClasses属性列表中去或者是配置文件中没有添加<mapping-class>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值