-->
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: one to many relation
PostPosted: Wed Jun 03, 2009 12:47 pm 
Newbie

Joined: Thu Jan 22, 2009 1:53 am
Posts: 5
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>



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.