-->
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.  [ 3 posts ] 
Author Message
 Post subject: net.sf.hibernate.MappingException
PostPosted: Mon Mar 22, 2004 11:03 am 
Newbie

Joined: Mon Mar 22, 2004 4:26 am
Posts: 3
I can't succeed in creating a simple mapping between two tables (order_item/product_catalog)

My Product is mapped as follow:
<hibernate-mapping package="com.xxx.bean">
<class name="ProductBean" table="TEST_product">
<id type="long">
<generator class="native"/>
</id>
<property name="code" column="CODE" not-null="true" access="field" unique="true"/>
<property name="type" column="TYPE" not-null="true" access="field" unique="false"/>
<property name="category" column="CATEGORY" not-null="true" access="field" unique="false"/>
<property name="min_qty" column="MIN_QTY" not-null="false" access="field" unique="false"/>
<property name="label" column="LABEL" not-null="false" access="field" unique="false"/>
</class>
</hibernate-mapping>

My ContractedProduct is mapped as follow:
<hibernate-mapping package="com.xxx.bean">
<class name="ContractedProductBean" table="TEST_contracted_product">
<id type="long">
<generator class="native"/>
</id>
<many-to-one name="product_ref_id" column="PRODUCT_REF_ID"/>
<property name="code" column="CODE" not-null="true" access="field" unique="true"/>
<property name="quantity" column="QUANTITY" not-null="false" access="field" unique="false"/>
</class>
</hibernate-mapping>

and my java classes have properties (id, and product_ref_id) declared as long (NOT java.lang.Long). I have also tried java.lang.Long but same result !!! argggg


Any ideas??? thanks a LOT!

jbg

when loading mappings, hibernate generates the following error:
net.sf.hibernate.MappingException: An association from the table TEST_contracted_product refers to an unmapped class: long
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:643)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:743)
at com.netonomy.bl.BLSession.<init>(BLSession.java:90)
at com.netonomy.generator.GenDB.populateDB(GenDB.java:76)
at com.netonomy.generator.GenDB.main(GenDB.java:45)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 22, 2004 5:25 pm 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
I'm new, but will give it a shot. I think you need to map the associated object to the actual class represented in the association --not to the tables FK column.

Somthing like:
<many-to-one name="product" column="PRODUCT_REF_ID"/>

rather than what you have:
<many-to-one name="product_ref_id" column="PRODUCT_REF_ID"/>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 9:51 am 
Newbie

Joined: Wed Mar 02, 2005 6:28 pm
Posts: 13
I did had the same error and after a lot of searching and trying I resolved this for me. You are may be using wrong type in the java onject.

You should correct the type of the field that maps to TEST_contracted_product column (in the java class).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.