`
星夜的遐想
  • 浏览: 188886 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.lyl

阅读更多
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.lyl.entity.Grade.school references an unknown entity: com.lyl.entity.School
	at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
	at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:474)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:295)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
	... 26 more

 

原因有二:

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

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

 <property name="annotatedClasses">
   <list>
    <value>com.lyl.entity.Grade</value>
    <value>com.lyl.entity.Student</value>
   </list>
  </property>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics