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!
|