I tried the documentation but I've got nothing. I tried searching for it on google and stackoverflow but there is still no help. I've got a singleton class and this class has a onetomany relationship to another class. Here's my code.
@Entity
public class HomeLibrary extends BaseModelObject {
@OneToMany(mappedBy = "homeLibrary", cascade = { CascadeType.ALL })
private Collection<Book> books = new ArrayList<Book>();
private static HomeLibrary sharedHomeLibrary = new HomeLibrary();
public static HomeLibrary getSharedHomeLibrary() {
return sharedHomeLibrary;
}
public Collection<Book> getBooks() {
return books;
}
public void setBooks(Collection<Book> books) {
this.books = books;
}
private HomeLibrary() {
}
}
And I got an error in testing. It seems that the table cannot be built.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [HibernateApplicationContext-aop.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on edu.fudan.ss.persistence.hibernate.Book.homeLibrary references an unknown entity: edu.fudan.ss.persistence.hibernate.HomeLibrary
See Question&Answers more detail:os