Many to Many Collections

From: Gary Cohan (spam_at_hotmail.com)
Date: 10/31/03


Date: Fri, 31 Oct 2003 18:18:51 -0000

Lets say you have two classes,

Product
and
Category.

In my e-commerce application, each category can have multiple products, and
each product and be on multiple categories.

So obviously, each Product has a collection of Category objects, and each
Category has a collection of Product objects.

My question is, if you wanted to add a product to a category and thus have a
new category <--> product mapping, would you expect to add the product to
the category, and then add the category to the product as two seperate
method calls, or is there some commonly used collection idiom that takes
care of this ?



Relevant Pages

  • Re: Many to Many Collections
    ... > In my e-commerce application, each category can have multiple products, ... > Category has a collection of Product objects. ...
    (comp.lang.java.programmer)
  • Re: Many to Many Collections
    ... > In my e-commerce application, each category can have multiple products, ... > Category has a collection of Product objects. ... You make the association at the same time, such that the product belonging ...
    (comp.lang.java.programmer)