-->
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: Querying on a many-to-many relationship question
PostPosted: Wed Oct 31, 2007 10:37 am 
Beginner
Beginner

Joined: Mon Aug 22, 2005 1:22 am
Posts: 36
I have Product and ProductCategory which are both first class objects, aka hibernate <class...> definition

ProductCategory has a parents and children both are ProductCategory's. Basically a tree of PC's

The Product and ProductCategory are in a many-to-many relationship. The tree path of PCs is stored in the relationship.

The relationship is not a first class object (i.e. ProductCategoryAssociation)

My question is there a way to query via Criteria to obtain the list of Products that have a certain tree path.

I have the SQL to get the result I want but would rather recreate via Java code.

SQL Example: (using MySql)
Note: hiq_manufacturer_product_category_product is the many-to-many table

Code:
select  pc.product_id from hiq_manufacturer_product_category_product pc
where pc.category_id in (105,601,653)
group by pc.product_id
having count(pc.product_id) = 3


Thanks in advance
- Doug


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.