Hibernate: Unable to load class declared in Hibernate configuration entry

后端 未结 10 1292
野趣味
野趣味 2021-01-21 01:03

I am completely new in Hibernate and got such an stacktrace:

hql> from TracksEntity 
[2014-04-26 21:13:45] org.hibernate.MappingException: Unable to load clas         


        
相关标签:
10条回答
  • 2021-01-21 01:16

    i recently experienced this. I checked everything and didn't find anything that might have caused it. In desperation, i just moved the "/>" closer in the mapping and saved it. And it worked. Mysterious...

    0 讨论(0)
  • 2021-01-21 01:19

    You can do it by two methods, 2nd one definitely works.

    1. Either adding a mapping entry in hibernate.cfg.xml should make it work

    <mapping class="com.sample.yourClass" />

    1. In your code, After you create Configuration object, Do add class like,
    Configuration config = new Configuration();
    config.addClass(com.sample.yourClass);
    
    0 讨论(0)
  • 2021-01-21 01:21

    Worked for me:

    Changing position of mapping tag in hibernate.cfg.xml for class which was not loading previously.

    I kept that at top now.

    0 讨论(0)
  • 2021-01-21 01:22

    In my case, I have just redeployed project. Then problem solved!

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