转自:https://blog.csdn.net/zheng0518/article/details/11029733

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>
---------------------
作者:onyas
来源:CSDN
原文:https://blog.csdn.net/zheng0518/article/details/11029733?utm_source=copy
版权声明:本文为博主原创文章,转载请附上博文链接!

org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.demo.pojo.IdCard的更多相关文章

  1. org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.entity.annotations.House.district in

    org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.entity. ...

  2. 020 <one-to-one>、<many-to-one>单端关联上的lazy(懒加载)属性

    <one-to-one>.<many-to-one>单端关联上,可以取值:false/proxy/noproxy(false/代理/不代理) 实例一:所有lazy属性默认(支持 ...

  3. JPA error org.hibernate.AnnotationException: No identifier specified for entity

    错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...

  4. 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...

  5. Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...

  6. org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误

    最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...

  7. org.hibernate.AnnotationException: No identifier specified for entity:

    使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...

  8. org.hibernate.AnnotationException: mappedBy reference an unknown target entity property

    org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: xxxxxxx 原因是 ...

  9. hibernate 一对一(One-to-One)

    一对一(one-to-one)实例(Person-IdCard) 一对一的关系在数据库中表示为主外关系.例如.人和身份证的关系.每个人都对应一个身份证号.我们应该两个表.一个是关于人信息的表(Pers ...

随机推荐

  1. Mongo优化笔记

    最近MongoDb服务器负载比较高,容易出问题,这里把优化的方式整理一下. 1.由于各个项目组共用一个mongo实例,所以一个项目组的问题会影响到别的项目组,所以需要把各个项目的数据从一个实例中剥离出 ...

  2. ( 转)Hibernate常用API

    http://blog.csdn.net/yerenyuan_pku/article/details/65103203 可在度娘上摘抄如下文字: Hibernate的核心类和接口一共有6个,分别为:S ...

  3. js的replace, 高亮

    ";console.log(str.replace(/\,/g, "")); //输出 123 ";console.log(str);//输出123 " ...

  4. Cesium学习笔记(四)Camera ----http://blog.csdn.net/hobhunter/article/details/74909641

    Cesium 相机控制场景中的视野.操作相机的方法有很多,如旋转,缩放,平移和飞到目的地.Cesium具有默认的鼠标和触摸事件处理程序与相机进行交互,还有一个API以编程方式操纵相机. 我们可以使用该 ...

  5. 如何用windbg查看_eprocess结构

    打开菜单: File->Symbol File Path... 输入: C:/MyCodesSymbols; SRV*C:/MyLocalSymbols*http://msdl.microsof ...

  6. 9.3.4 BeaufitulSoup4

    BeautifulSoup 是一个非常优秀的Python扩展库,可以用来从HTML或XML文件中提取我们感兴趣的数据,并且允许指定使用不同的解析器. 使用 pip install BeaufifulS ...

  7. 【DIP Learining MFC &OpenCV】 Experience by 20171026

    This day saw the progress I achieved in creating a fusion of MFC frame and OpenCV code as well as so ...

  8. Codeforces Round #413(Div. 1 + Div. 2, combined)——ABCD

    题目在这里 A.Carrot Cakes 乱七八糟算出两个时间比较一下就行了 又臭又长仅供参考 #include <bits/stdc++.h> #define rep(i, j, k) ...

  9. CDOJ 889 Battle for Silver

    Battle for Silver Time Limit: 2999/999MS (Java/Others)     Memory Limit: 65432/65432KB (Java/Others) ...

  10. 洛谷 P3258 BZOJ 3631 [JLOI2014]松鼠的新家

    题目描述 松鼠的新家是一棵树,前几天刚刚装修了新家,新家有n个房间,并且有n-1根树枝连接,每个房间都可以相互到达,且俩个房间之间的路线都是唯一的.天哪,他居然真的住在”树“上. 松鼠想邀请小熊维尼前 ...