I have a complex database that's looking like this:
product *1 <-> n* inventory *n <-> 1* inventoryUser *1 <-> n* user
Now I would like to query e.g. all products where user.firstname = 'peter' in hql.
I have a complex database that's looking like this:
product *1 <-> n* inventory *n <-> 1* inventoryUser *1 <-> n* user
Now I would like to query e.g. all products where user.firstname = 'peter' in hql.
In your entities and mappings you should have references for each of these relations. And your HQL query will look like:
SELECT p FROM Product p, IN(p.inventory.inventoryUser) AS iu
WHERE iu.username=:username
I figered out how to handle it:
Product as p join fetch p.inventories as i join fetch i.inventoryUser as iu join fetch iu.user as u where u.name=:name