There may already be an answer for this on the forum somewhere because it is a common problem, but apparently I don't know what the right search terms for it would be to find it, so here it goes:
I have a product table, category table, and a product_category table that links the two. What is the best way to pass in a category id and get all the product rows for that category id?
Do I just do something like this:
Code:
List<ProductCategory> productCategories = getHibernateTemplate().find("from product_category where product_t = ? order by category_order", categoryId);
List<Product> products = new ArrayList<Product>();
for (ProductCategory productCategory : productCategories)
{
products.add(productCategory.getProduct());
}
return products;
Is there a better way?