This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Mapping issue in hibernate.cfg.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Mapping issue in hibernate.cfg.xml" Watch "Mapping issue in hibernate.cfg.xml" New topic
Author

Mapping issue in hibernate.cfg.xml

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 111

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

Joined: Aug 09, 2005
Posts: 61
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

Joined: Aug 05, 2011
Posts: 111

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping issue in hibernate.cfg.xml
 
Similar Threads
Could not parse mapping document from resource developerhelpway/hibernate/employee.hbm.xml
Noob error :org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]
No suitable driver found for oracle:jdbc:thin:@localhost:1521:xe Exception ;Hibernate
Not able to view the data persisted in the database.
Hibernate problem