I have a complex database that looks like this:
product *1 <-> n* inventory *n <-> 1* inventoryUser *1 <-> n* user
Now I would like to request, for example. all products where user.firstname = 'peter' in hql.
I figured out how to handle this:
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
In your entities and mappings, you must have references for each of these relationships. And your HQL query will look like this:
SELECT p FROM Product p, IN(p.inventory.inventoryUser) AS iu WHERE iu.username=:username
Source: https://habr.com/ru/post/1730845/More articles:What makes an efficient implementation of URL mapping and why? - djangoMemory error. Highlighting ... - gprofВалюты UILabel + IRR, KRW и KHR с неправильным символом - iphoneMVC last chance to change the response before it is passed to the user - asp.net-mvcWhy am I getting a “no listener” error when using Rails with Oracle? - ruby | fooobar.comMutex over the network - C # .NET - c #Tray app takes up 40 MB in xp and 10mb in win7 - c #parallel access to the method - c #How to emulate the behavior of a request scope in a bean session scope? - javaHow to add combobox and button to info area on google map? - iphoneAll Articles