org.hibernate.MappingException: Unknown entity

You have to list your classes in your session factory configuration. You can have your entities auto-discovered if you are using EntityManager.

In order to use annotations with hibernate and spring, you have to use AnnotationSessionFactoryBean:

 <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="annotatedClasses">
        <list>
            <value>edu.acct.tsegay.model.User</value>
        </list>
    </property>
    ....
 </bean>

Also, it is rather strange that your User entity is a spring bean. You don't need that. Hibernate entities are supposed to be created with the new operator.


I've encountered the same problem and didn't find any good answer for this

What worked for me was to declare my entity class in the persistence.xml file:

<persistence ...>
    <persistence-unit ...>

        <class>com.company.maenad.core.model.News</class>
        <class>com.company.maenad.core.model.AdExtraInfo</class>

    </persistence-unit>
</persistence>