-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping and named query issue with composite key many to one
PostPosted: Thu Sep 02, 2010 11:17 am 
Newbie

Joined: Thu Sep 02, 2010 10:47 am
Posts: 2
I have three tables, one of which is a relationship table between the other two. For simplicity sake, here are the relevant tables/columns (I did not design these tables or their naming, don't yell at me lol):

table: povendsite
column: vendno
column: vend_site

table: rt_sub_category
column: category
column: sub_category

table: store_services_vend_subcat
column: vendno
column: vend_site
column: category
column: sub_category

the first two tables above are two tables that have rleationships stored in the third table. I have three objects for these tables, mappings are as follows (relevant parts):

<class name="VendorSite" table="povendsite">
<composite-id name ="id" class="VendorSiteKey">
<key-many-to-one name="vendor" column="vendNo" class="Vendor" lazy="false"/>
<key-property name="siteNo" column="site_no"/>
</composite-id>

<class name="SubCategory" table="rt_sub_category">
<composite-id name ="id" class="SubCategoryKey">
<key-property name="subCategory" column="sub_category" />
<key-property name="category" column="category" />
</composite-id>

<class name="VendorSubCategoryRelationship" table="vendor_subcateories">
<composite-id name ="id" class="VendorSubCategoryRelationshipKey">
<key-many-to-one name="vendorSite" column="site_No" class="VendorSite" lazy="false">
<column name="vendno"/>
<column name="site_no"/>
</key-many-to-one>
<key-many-to-one name="subCategory" class="SubCategory" lazy="false">
<column name="sub_category" />
<column name="category"/>
</key-many-to-one>
</composite-id>


All this being said, I need a named query (I think this is the best way to go here) where I will be given a subcategory and I need to find all of the vendor sites (combination of vendno and vend_site) that do not currently have a relationship with that category/subcategory combination. I have no idea how to start writing this named query...any ideas?


Top
 Profile  
 
 Post subject: Re: Mapping and named query issue with composite key many to one
PostPosted: Thu Sep 02, 2010 11:17 am 
Newbie

Joined: Thu Sep 02, 2010 10:47 am
Posts: 2
oh I forgot to mention, I am using Java 1.4 and hibernate 3 :)


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