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

Mapping issue in hibernate.cfg.xml

 
vivek dhiman
Ranch Hand
Posts: 153
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi during the execution of simple Java Program Configuration file not able to load the .hbm file. I have done few example in netbeans but in eclipse this encountered. Below is my code under eclipse java project.

Below is my Main Class

My mapping file that is in com package :

My hibernate.cfg.xml that is under src :

I am getting the error :



Please help Don't let me to swich to Netbeans.
 
Reddy Prashanth
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your hibernate.cfg.xml file, below line is not valid.
<mapping class="com.Person.hbm.xml"/>

For class attribute, use class name as below
<mapping class="com.fooPackage.AnotherModelClass" />

Or, use
<mapping resource="com/Person.hbm.xml"/>

Also, if you already mention the mapping file name or class name in the hibernate.cfg.xml, then below line is redundant.
Configuration cfg = new Configuration().addResource("person.hbm.xml").configure();
 
vivek dhiman
Ranch Hand
Posts: 153
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr. Reddy. This works now, just made 2 changes.
&


This site is really good & popular just because this reason. Place where i was stuck from last 1 days solved in 1 hr.

thank you again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic