org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.demo.pojo.IdCard
2013-09-04 09:51
309 查看
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>
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>
相关文章推荐
- org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: com.bjsxt.model.Student.courses
- org.hibernate.AnnotationException: @Column(s) not allowed on a @ManyToOne property: entity.KpsysLog
- Hibernate 异常:“@OneToOne or @ManyToOne on XXX references an unknown entity: XXX”
- org.hibernate.AnnotationException: Referenced property not a (One|Many)ToOne: in mappedBy of
- JPA保存数据异常:org.hibernate.AnnotationException: @COLUMN(s) NOT allowed ON a @ManyToOne property
- org.hibernate.AnnotationException: @Column(s) not allowed on a @ManyToOne property: entity.KpsysLog.
- org.hibernate.PropertyNotFoundException: Could not find a getter for employee in class com.itcast.f_hbm_oneToMany.Department
- Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
- org.hibernate.UnknownEntityTypeException: Unable to locate persister: com.taotao.pojo.TbItem
- hibernate manyToOne lazy to one Annotation
- org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned b
- Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be
- mybatis中的一个异常:org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to
- hibernate 的many to one 的问题IllegalArgumentException occurred while calling setter of hibernatePOJO
- org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property
- org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned b
- TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 3
- org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.chen.vo.Dept.parentId
- Hibernate_OneToMany_Demo
- Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误