I do this by creating a 3rd table which stores groups. For example

table product:            table categoryList            table productGroup
-----------------            --------------------            ---------------
-------
product_id                    list_id                            group_id
product_name               product_id                     group_name
product_list_id             group_id                        product_list_id

(This is pseudo-code at best)

To list all products for a group:

crit.addJoin(productPeer.product_list_id, categoryListPeer.list_id);
crit.addJoin(categoryListPeer.group_id, productGroupPeer.group_id);
crit.add(productGroupPeer.group_name, "widgets");
Vector v = product.doSelect( crit );

To list all groups for a product:
crit.addJoin(productGroupPeer.product_list_id, categoryListPeer.list_id);
crit.addJoin(categoryListPeer.product_id, productPeer.product_id);
crit.add(ProductPeer.product_name, "Spacely Sprocket");
Vector v = productGroupPeer.doSelect( crit );

I hope I didn't skip/confuse anything here, but I hope you get the concept.

Steve B.

----- Original Message -----
From: "Rooms, Christoph" <[EMAIL PROTECTED]>
To: "'Turbine Torque Users List'" <[EMAIL PROTECTED]>
Sent: Friday, June 14, 2002 8:07 AM
Subject: How to do this ...


> Hi all,
>
> I am using Torque for a few days now and it ROCKS !
>
> Anyway ... How can I solve this using Criteria ?
>
> I have an n:m relation ship.
>
> Ex : product / productgroup and a product can be in multiple product
groups,
> and the other way around.
>
> Ok ... How can I get a list of all the products that are not connected to
> productgroup = "1"
>
> Is this done with the addNotIn ?
>
> Thanks, Christoph
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to