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