-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Initial SessionFactory fails because of Mapping file
PostPosted: Wed Oct 31, 2007 12:58 pm 
Newbie

Joined: Tue Oct 16, 2007 3:42 pm
Posts: 11
hi,

i'm trying to set up a simple hibernate application, where i have two tables in my database, represented by two POJOs (Group.java and Story.java). I am using PostgreSQL as my database.

My problem is that I am getting the following exception when this line of code executes:

sessionFactory = new Configuration().configure().buildSessionFactory();

Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource Group.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError

The Group.hbm.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="Group" table="grouptable">
<id name="id" unsaved-value="0">
<generator class="increment"/>
</id>

<set name="stories" cascade="all" inverse="true">
<key column="parent_id"/>
<one-to-many class="Story"/>
</set>

<property name="name" type="string"/>
</class>
</hibernate-mapping>

My hibernate.cfg.xml file is as follows:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/hibernateTutorial</property>
<property name="connection.username">postgres</property>
<property name="connection.password">mypassword</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Mapping files -->
<mapping resource="Group.hbm.xml"/>
<mapping resource="Story.hbm.xml"/>
</session-factory>
</hibernate-configuration>


I can't figure out why I'm getting the error for "could not parse mapping document from resource Group.hbm.xml".

Any guidance as to where I may be going wrong will be very helpful.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.