JPQL/JPA query with collections

Hi!

I hope that this is the right forum. I have a simpe datamodel like Company----products.category. I tried to make a select with JPQL like that:

Query q = em.createQuery(“SELECT x FROM Company x WHERE x.products.category='”+cProduct+“'”);

I got that:

java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: |Exception Description: Error compiling the query [SELECT x FROM Company x WHERE x.products.category=‘’]
, line 1, column 32: invalid navigation expression [x.products.category]
, cannot navigate collection valued association field [products]
.

So is it even possible to make a selection like that with JPA or am I just doing something wrong? Any ideas?

Thanks!
Sami