Hello. I am trying to make my first composite-id mapping file and I get an InvalidMappingException when i call the configure method in the Configure class.
I have 2 tables: Stock and StockPrice, here is the definition in postgresql:
Code:
CREATE TABLE stock
(
  id serial NOT NULL,
  symbol varchar(20) NOT NULL,
  CONSTRAINT pk_stock PRIMARY KEY (id)
) 
CREATE TABLE stockprice
(
  date date NOT NULL,
  stockid int4 NOT NULL,
  price numeric(12,5) NOT NULL,
  CONSTRAINT pk_stockprice PRIMARY KEY (date, stockid),
  CONSTRAINT fk_stockprice__stock FOREIGN KEY (stockid)
      REFERENCES stock (id) MATCH SIMPLE
      ON UPDATE RESTRICT ON DELETE RESTRICT
) 
I created the Stock, StockPrice and StockPricePK classes with a default constructor, the getters and setters methods, override equals and hashCode and StockPrice implements Serializable. Here is the mapping files for both classes:
Stock.hbm.xml:
Code:
<hibernate-mapping>
    <class name="Stock" table="stock">
        <id name="_id" column="id">
            <generator class="sequence">stock_id_seq</generator>
        </id>
        <property name="_symbol" column="symbol" not-null="true" unique="true" />
        <map name="_prices" lazy="true"> 
            <key column="date" />
            <one-to-many column="stockid" class="domain.StockPrice" />
        </map>
    </class>
</hibernate-mapping>
StockPrice.hbm.xml:
Code:
<hibernate-mapping>
    <class name="StockPrice" table="stockprice">
        <composite-id class="domain.StockPricePK">
            <key-property name="_date" column="date"/>
            <key-many-to-one name="_stockId" column="stockid" class="domain.Stock"/>
        </composite-id>
        <property name="_price" column="price" not-null="true" />
    </class>
</hibernate-mapping>
This is the code i am using to create the session factory:
Code:
public static SessionFactory getSessionFactory()
    {
        if(_sessionFactory == null)
        {
            Configuration configuration = new Configuration().configure();
            _sessionFactory = configuration.buildSessionFactory();
        }
        
        return _sessionFactory;
    }
This is the line where the exceptino is throwed: 
Configuration configuration = new Configuration().configure();
The exception stacktrace is the following:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource domain/StockPrice.hbm.xml
	org.hibernate.cfg.Configuration.addResource(Configuration.java:523)
	org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1511)
	org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
	org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
	org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
	org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
	org.hibernate.cfg.Configuration.configure(Configuration.java:1338)
	helper.HibernateHelper.getSessionFactory(HibernateHelper.java:21)
	servlet.TestServlet.doGet(TestServlet.java:29)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I am using jdk 1.4.2 and Hibernate 3 with postgresql 8.0. Here is the hibernate.cfg.xml:
Code:
<hibernate-configuration>
    <session-factory>
        <property name="connection.datasource">java:/comp/env/jdbc/hibernateDB</property>
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="show_sql">false</property>
        <mapping resource="domain/StockPrice.hbm.xml" />
        <mapping resource="domain/Stock.hbm.xml" />        
    </session-factory>
</hibernate-configuration>
I hope you can help me.
Regards