my environment;myeclipse 7, hibernate 3, spring 2.5
tables;product , product_category, category(one to many, many to one relationship)
I generate DAO of three tables using hiberante reverse engineering.
I can not see product_category table. i don't know why? how can i generate product_category table, without product_category table , product.hbm has an error message.
Caused by: org.hibernate.MappingException: Association references unmapped class: mydao.hibernate.ProductCategory
Code:
<hibernate-mapping>
<class name="mydao.hibernate.Product" table="PRODUCT" schema="CS">
<id name="id" type="java.lang.String">
<column name="ID" length="20" />
<generator class="sequence" />
</id>
<property name="name" type="java.lang.String">
<column name="NAME" length="50" not-null="true" />
</property>
<property name="price" type="java.math.BigDecimal">
<column name="PRICE" precision="22" scale="0" />
</property>
<property name="width" type="java.math.BigDecimal">
<column name="WIDTH" precision="22" scale="0" />
</property>
<property name="height" type="java.math.BigDecimal">
<column name="HEIGHT" precision="22" scale="0" />
</property>
<property name="description" type="java.lang.String">
<column name="DESCRIPTION" length="4000" />
</property>
<set name="productCategories" inverse="true">
<key>
<column name="PRODUCT_ID" length="20" not-null="true" />
</key>
<one-to-many class="mydao.hibernate.ProductCategory" />
</set>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="mydao.hibernate.Category" table="CATEGORY" schema="CS">
<id name="id" type="java.math.BigDecimal">
<column name="ID" precision="22" scale="0" />
<generator class="sequence" />
</id>
<property name="name" type="java.lang.String">
<column name="NAME" length="50" not-null="true" />
</property>
<property name="description" type="java.lang.String">
<column name="DESCRIPTION" />
</property>
<set name="productCategories" inverse="true">
<key>
<column name="CATEGORY_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="mydao.hibernate.ProductCategory" />
</set>
</class>
</hibernate-mapping>