June 2018
Intermediate to advanced
408 pages
11h 23m
English
It is always recommended to select only those columns which are required for our use case. If you are using the CriteriaQuery, use projections to select required columns. Fetching the entire entity would degrade the application's performance when the table has too many columns, so the database needs to go through each block of the stored page to retrieve them, and we might not even need all of those columns in our use case. Also, if we are using an entity instead of the DTO class, persistence context has to manage the entities and also fetches associated/child entities when required. This adds an overhead. Instead of fetching the entire entity, fetch only the required columns:
SELECT a FROM Account a WHERE a.accountId= ...
Read now
Unlock full access