MappedBy reference an unknown target entity property [How to Solve]

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

 

The above is the key part of the error

The reason for the error: In the one-to-many annotation configuration: @OneToMany (mappedBy = “Articles”), mappedBy points to the attribute to be associated, not the class to be associated.
If this is configured, hibernate will find com.wangzhe. Articles property under the model.Keyword class. But in fact without this attribute, the above exception
method will be reported : Assign to the actual associated attribute: namely: @OneToMany (mappedBy = “articles”)

 

Similar Posts: