Hello all!
I have a following problem with Hibernate application which I develope in
Eclipse environment.
Application is a simple
Java standalone program and it has
hibernate.cfg.xml file and a class for mapping a class to DB.
Hibernate.cfg.xml file is read without problems but
everytime in code when Configure class is invoking addClass-method
MappingException is thrown.
E.g.call
cfg.addClass(Product.class);
throws
08-Oct-2004 10:57:22 net.sf.hibernate.cfg.Configuration addClass
INFO: Mapping resource: hibertest/Product.hbm.xml
Exception in
thread "main" net.sf.hibernate.MappingException: Resource: hibertest/Product.hbm.xml not found
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:352)
at hibertest.HibTestMain.main(HibTestMain.java:38)
I have strugled with this 2 and half days
Where does Hibernate actually reads XML mapping files?
I have put all my XML files to same place which is in the root of
Eclipse project so, if hibernate.cfg.xml is found should'n mapping XMLs found too?
I have following hibernate.cfg.xml file:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">
jdbc ostgresql://localhost/TesterDB </property>
<property name="show_sql">false</property>
<property name="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="dialect">
net.sf.hibernate.dialect.PostgreSQLDialect
</property>
<property name="hibernate.connection.username">usepostg</property>
<property name="hibernate.connection.password" />
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<!-- Mapping files -->
<mapping resource="Product.hbm.xml" />
</session-factory>
</hibernate-configuration>
and Product.hbm.xml file for class OR mapping is:
?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="hibertest.Product" table="Product">
<id name="id" type="string"
unsaved-value="null">
<column name="id" sql-type="varchar(32)"
not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="name" type="java.lang.String">
<column name="name" sql-type="varchar(32)"
not-null="true"/>
</property>
<property name="price" type="java.lang.Double">
<column name="price" sql-type="int8"
not-null="true"/>
</property>
<property name="amount" type="java.lang.Long">
<column name="amount" sql-type="int4"
not-null="true"/>
</property>
</class>
</hibernate-mapping>