mappedBy reference an unknown target entity property解决方法

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘articleDaoImpl‘: Injection of resource methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory‘ defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.wangzhe.model.Keyword.Articles in com.wangzhe.model.Article.keywords

 

上面是错误的关键部分

  错误原因:在one-to-many注解配置: @OneToMany (mappedBy = "Articles"),mappedBy指向的是要关联的属性,而不是要关联的类,
        如果这样配置,hibernate则会找com.wangzhe.model.Keyword类下面的Articles 属性。但实际上没有这个属性,就会报上面的异常
   方法:指定到实际关联的属性:即:@OneToMany (mappedBy = "articles ")

mappedBy reference an unknown target entity property解决方法,布布扣,bubuko.com

mappedBy reference an unknown target entity property解决方法

上一篇:【我所认知的BIOS】—> uEFI AHCI Driver(4) — 第一个Protocol真难搞


下一篇:IOS开发中的UITableView与UITableViewCell