Little correction in you case num of employees: 7 but only 3 assistant query is executed so u have problem of 3+1 issue but it should be 7 plus 1 problem. The problem here is you need to execute “from employee” then for each employee related departments will be executed. So here N is num of department not employee
@naranivenkatreddy6801
5 жыл бұрын
if departments are 3 like IT, EEE, ECE, in the table when you will fetch all department and under the employee details from the table how many queries will generate for department......? can you explain to me
@ambidextrousTrades
5 жыл бұрын
So totally there will be 4 queries that will execute (1 to get all the department info + 3 queries to get all employees for each type of department) why 3? IT, EEE, ECE. Hence the name N+1 problem where N is the type of departments and 1 being the main query to get all department info without the employee info. The solution is to use JOINS so that instead of 4 queries, we can get everything in just 1 query. This helps us prevent making N+1 number of queries and instead make just 1 query to get everything we need.
@balasubrahmanyam1149
3 жыл бұрын
@@ambidextrousTrades Nice explanation
@pratikisgr8888
6 жыл бұрын
Nice example I liked it.
@shivakiran2176
4 жыл бұрын
I understood the concept but 1 question when tried to execute the program i got 7 results for departments but i have 3 records in db , so i go to your github and copied your code and ran, same problem, Can you please explain why this is happening ?
@vaibhavsarje2932
4 жыл бұрын
How to solve this problem using jpql??
@ravindra0295
6 жыл бұрын
if possible please explain hibernate bootstrapping and contextual session........ please 1000000s
@pawansalwan17
6 жыл бұрын
Nice tutorials thanks
@Kriishna47
6 жыл бұрын
I still can't get the notion of child and parent in your example. How come dept and employee are child and parent? It is not an inheritance, it is Composition isn't it?
@KKJavaTutorials
6 жыл бұрын
+Krishna ,Here in this example one department can have many employees that why I m referring dept as parent that's what we think in JPA world..dont it compare it with Java inheritance...
Пікірлер: 13