Hi Markus,

The problem is that each product can have more than one category and I
cannot query 'SELECT p.Category'.  Is there something in HQL that can
handle such associations ?

Mark

On Jun 13, 7:30 am, Markus Zywitza <[email protected]> wrote:
> Why don't you use HQL for that, it is dead simple:
>
> select p.Category from Product p where p.Brand = ?
>
> -Markus
>
> Am 13. Juni 2010 06:43:28 UTC+2 schrieb Mark Borg <[email protected]>:
>
>
>
> > OK Guys, solved using a native SQL query
>
> > SELECT * FROM prod_productcategory pc
> > JOIN prod_productcategories pcs ON pc.id = pcs.productCategoryId
> > JOIN prod_product p ON pcs.productId = p.id
> > AND p.productBrandId = :productBrandId;
>
> > On Sun, Jun 13, 2010 at 5:57 AM, ubahn <[email protected]> wrote:
>
> >> Hi all,
>
> >> I have the following model:
>
> >> Each Product is linked with a ProductBrand
> >> Each Product has a HasAndBelongsToMany relationship with
> >> ProductCategory
>
> >> and what I`m trying to retrieve is a list of product categories for a
> >> given product brand if there are products linked with that brand
>
> >> Can someone give me a hand on this one ....
>
> >> Thanks
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Castle Project Users" group.
> > To post to this group, send email to [email protected]
> > .
> > To unsubscribe from this group, send email to
> > [email protected]<castle-project-users%2Bun 
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/castle-project-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to