• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.MappingException: Unknown entity: com.training.HelloWorld

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello I tried to run a hibernate 2 example but getting org.hibernate.MappingException: Unknown entity: com.training.HelloWorld ... Please help. Can see my code below


















 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inconsistent package

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
T Mishra wrote:Inconsistent package



Package is right in my code just forget to made change here. but still having issues with it.
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace
<mapping class="com.training.HelloWorld"/>

by
<mapping resource="path/to/.hbm.xml"/>

an example xml configuration
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
T Mishra wrote:Replace
<mapping class="com.training.HelloWorld"/>

by
<mapping resource="path/to/.hbm.xml"/>

an example xml configuration


Getting
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Assuming the name of the above file is HelloWorld.hbm.xml.
path/to/.hbm.xml

you have to specify path to the HelloWorld.hbm.xml.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the same code was working during tutorial but not on my system. is there any particular configuration required for it?
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kaustubh G Sharma wrote:
Hello I tried to run a hibernate 2 example but getting org.hibernate.MappingException: Unknown entity: com.training.HelloWorld ... Please help. Can see my code below


















 
Maki Jav
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is, why am I required to declare in the hibernate.cfg.xml

<mapping class="com.ev.hcm.model.Role"/>

where as I am using annotations. Here is my class:



if I declare that mapping class then I get it compiled otherwise I get the same exception, ie, org.hibernate.MappingException: Unknown entity: com.ev.hcm.model.Role

What am I doing wrong?

I am using hibernate3.jar.

Thanks in Advance,

Maki Jav
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic