Hibernate problem – “Use of @OneToMany or @ManyToMany targeting an unmapped class”

Your annotations look fine. Here are the things to check:

  • make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition.
  • if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed the ScopeTopic entity
  • make sure you don’t have multiple ScopeTopic classes in different packages, and you’ve imported the wrong one.

Leave a Comment