Hibernate - Rollback :org.hibernate.MappingException: Unknown entity

后端 未结 1 1726
遥遥无期
遥遥无期 2021-01-16 16:07

I have written few codes for inserting data into my SQL database. Actually, I am trying to learn Struts2 with Hibernate. But, unfortunately I am facing a problem after submi

相关标签:
1条回答
  • 2021-01-16 16:31

    If the entity isn't mapped, you should inspect the hibernate configuration. Hibernate is ORM framework used to map pojos (entities) to the database schema objects. You didn't configure or hibernate couldn't find mapping for the object Employee. The configuration file is hibernate.cfg.xml should contain the mapping to the resource Employee.hbm.xml. Suppose this file is in the same folder as Employee class. Then the mapping will be

    <mapping resource="v/esoft/pojos/Employee.hbm.xml"/>
    

    Another approach if you used an annotation based configuration, then you should use class attribute to map to the pojo that contains Hibernate/JPA annotations.

    <mapping class="v.esoft.pojos.Employee"/>
    

    Note, annotation based Configuration might be different depending on version of Hibernate and may require additional libraries.

    0 讨论(0)
提交回复
热议问题