@OneToOne or @ManyToOne on references an unknown entity:

简介:

1使用hibernatespring MVC 时报错:

Xml代码   收藏代码
  1. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.apidoc.entity.APIOne.APIGroup references an unknown entity: com.apidoc.entity.APIGroup  
  2.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)  
  3.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)  
  4.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)  
  5.     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)  
  6.     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)  
  7.     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)  
  8.     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)  
  9.     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:442)  
  10.     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:416)  
  11.     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:550)  
  12.     at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:159)  
  13.     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)  
  14.     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)  
  15.     ... 23 more  
  16. Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.apidoc.entity.APIOne.APIGroup references an unknown entity: com.apidoc.entity.APIGroup  
  17.     at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:109)  
  18.     at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1536)  
  19.     at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1457)  
  20.     at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1365)  
  21.     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1756)  
  22.     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)  
  23.     at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247)  
  24.     at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373)  
  25.     at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358)  
  26.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)  
  27.     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)  
  28.     ... 35 more  

 最后发现是,类缺少了@Entity 注解

 

 

相关文章
|
4月前
|
SQL Java 数据库连接
Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have a de
Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have a de
### Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have
### Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value; Field ‘id‘ doesn‘t have
|
数据库
Field ‘id‘ doesn‘t have a default value
Field ‘id‘ doesn‘t have a default value
166 0
|
数据库
Incorrect table definition; there can be only one auto column and it must be defined as a key
Incorrect table definition; there can be only one auto column and it must be defined as a key
175 0
Incorrect table definition; there can be only one auto column and it must be defined as a key
When will the reference ATTRIBUTE_REF of an BOL entity be cleared
When will the reference ATTRIBUTE_REF of an BOL entity be cleared
117 0
When will the reference ATTRIBUTE_REF of an BOL entity be cleared
How to update BOL entity property value via ABAP code
How to update BOL entity property value via ABAP code
112 0
How to update BOL entity property value via ABAP code
|
存储 Java
Java Primitive type与References type
Java语言规格文档与JVM规格文档不一致... surprice Java是一种强类型语言,它语言规范中定义了Java的数据类型分为,基本数据类型和引用数据类型。