Hello!
I have a question. I have two entities, say, item and shop, in a many-to-many relation. Let's assume shop A sells items 1, 2, 3 but not 4. While shop B sells items 2, 3, 4 but not 1. Entity Shop has a set of Items, and Item has a set of Shops as property.
Now I want to query two things using HQL:
1. give me the number (count(*)) of items sold at shop A.
2. give me the first 20 items from a start index, say 147, so they can be displayed on the webpage, ordered by their name
Now, the same thing for ALL items is quite easy:
Code:
Query q1 = hibernateSes.createQuery("select count(i) from Item as i");
Query q2 = hibernateSes.createQuery("select i from Item as i order by i.name");
int num = q1.uniqueResult().intValue();
q2.setMaxResults(20);
q2.setFirstResult(147);
How can I achieve the same thing, only for Items sold at shop A ???
Thank you very much!
Bastian
Hibernate version: 2.1.7