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?
|