Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InvalidMappingException in Hibernate

 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I got thousand and thousand of errors using hibernate.This is my dir structure.


I use MySQL for database.I have these libs in the lib.

hibernate3.jar
antlr-2.7.6.jar
commons-collations-3.1.jar
dom4j-1.6.1.jar
javassist-3.9.0.GA.jar
jta-1.1.jar
slf4j-api1.5.8.jar
mysql-connector-java-5.1.9.jar

When I run , I got this error



and more error messages (in the case you want to see,I will show you later)

According to the error message , I think this error is from Employee.hbm.xml.So, the following is the content of that mapping file.



is something wrong with mapping file? Somebody help me please when you are free. I am in trouble.




 
Amar Deep Singh Chaudhary
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not able to see the Employee class in your structure, i think you have missed to display that, can you also upload the code of that class here , so that i can look into that and helpout you.

Thanks
With Regards
Amar Deep Singh
http://amardeep.100webspace.net
 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh sorry, I edited my structure.
and the code of Employee is as follow

 
Amar Deep Singh Chaudhary
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please also include your hibernate.cfg.xml file
 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, this is my hibernate.cfg.xml



then I try to configure hibernate like this



I don't think there is something wrong with hibernate cfg file, may be the error comes from mapping hbm file.(in my case Employee.hbm.xml)
 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I post the left error messages so that you will able to find out.

 
Christian Dillinger
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have an id-Field. So this part of the class-Tag is missing: (id|composite-id)

You need an id oder composite-id.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also a suggestion, if you have space before "<?xml version="1.0"?> ", remove it.
I remember getting this error for the space before the above.
 
Yewint Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh....yes, I got it. It works fine.Thanks you all.
But ,why do I have to add id field? Does it mean that every table in database must have ID column?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic