Hibernate unknown entity (not missing @Entity or import javax.persistence.Entity )

前端 未结 6 1452
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 13:22

I\'ve got a really simple class:

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.pers         


        
6条回答
  •  没有蜡笔的小新
    2020-12-16 13:50

    Consider using AnnotationConfiguration described here.

    You could either use its addClass(User.class) method, or if you're persisting multiple entities use the addPackage("org.assessme.com.entity") method.

    You're kind of reinventing the wheel with this HibernateUtil class. Consider using Spring so you can leverage something like its AnnotationSessionFactoryBean.

提交回复
热议问题