Java – Hibernate/JPA Annotations — Unknown Entity

annotationshibernatejavajpa

An application that has been working well for months has stopped picking up the JPA @Entity annotations that have been a part of it for months. As my integration tests run I see dozens of "org.hibernate.MappingException: Unknown entity: com.whatever.OrderSystem" type errors.

It isn't clear to me what's gone wrong here.

I have no hibernate.cfg.xml file because I'm using the Hibernate Entity Manager. Since I'm exclusively using annotations, there are no .hbm.xml files for my entities. My persistence.xml file is minimal, and lives in META-INF as it is supposed to.

I'm obviously missing something but can't put my finger on it.

I'm using hibernate-annotations 3.2.1, hibernate-entitymanager 3.2.1, persistence-api 1.0 and hibernate 3.2.1. hibernate-commons-annotations is also a part of the project's POM but I don't know if that's relevant.

Is there a web.xml entry that has vanished, or a Spring configuration entry that has accidentally been deleted?

Best Answer

verify in your entity classe that you import javax.persistent.Entity and not org.hibernate.annotations.Entity