I have a question on retrieving the entities from JPA
Consider a employee entity
If i have an dept id and want to get all employees, the only option i see is
This will fire two queries, one on the dept and then on employees (lazy loading)
But i am interested only in employees, there are no options in jpa to get this even using query (as there are no dept id in employee object). The reason i am asking is, when i am interested only in Employee, why to query Dept (what if it has 100's of more attributes which are not relevant).
Kindly let me know if this is the only way to resolve.
Thanks in advance
posted 2 years ago
Of coarse if the Department was already in the cache, the find on it and access to its employees would be the most efficient way to access the employees.