-->
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.  [ 4 posts ] 
Author Message
 Post subject: Collection mapping : <map>
PostPosted: Thu Jul 28, 2005 1:29 am 
Beginner
Beginner

Joined: Fri Jun 25, 2004 5:31 am
Posts: 31
Hibernate version:3

Name and version of the database using: Oracle 8i

Can anyone give example of how to specify the mapping for <map> instead of a list or a set? My senario is mentoned below:

where:

PRODUCT (PRODUCT_CODE, DESCRIPTION)
PART (PART_CODE, DESCRIPTION)
PRODUCT_PART (PRODUCT_CODE , PART_ID)

In the Product.hbm.xml how to specify the mapping for PRODUCT_PART table via a <map> ?

pls help

thanks
Shanika


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 4:49 am 
Newbie

Joined: Fri Jul 15, 2005 7:22 am
Posts: 3
The Problem is not to give you an example for a map, but the example you are giving is a one-to-many relation between PRODUCT and PART. So you have one PRODUCT with a set or list of PARTs.

If you want to use a map than what should be the key and the value?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 6:03 am 
Beginner
Beginner

Joined: Fri Jun 25, 2004 5:31 am
Posts: 31
I was able to do this with using a Set. But now need to try it with a Map.


This is the way i gave the mapping which is in the Product.hbm.xml
:

Quote:
<map name="product_parts" table="PRODUCT_PART">
<key column="PRODUCT_CODE" not-null="true"/>
<map-key type="java.lang.String" column="PART_ID" />
<many-to-many class="eg.Part" column="PART_CODE"/>
</map>



I have DAO s and HBM s only for the PRODUCT and PART tables. PRODUCT_PART is a pure resolving table, which does not have a DAO and is mapped in the PRODUCT hbm.xml as shown above.


This gives an invalid column exception when a query is executed. But there arn't any mapping error at the JBoss start up.



thanks
Shanika


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 6:42 am 
Newbie

Joined: Fri Jul 15, 2005 7:22 am
Posts: 3
So you already answered your question and found a mapping.

If you want someone to have a look on your select than post the code and the exception and we'll see.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.