Re:Problems with JPA/Hibernate
by chrisandchris on Monday April 12, 2021 @04:33AM
(#26777134)
How do you deal in such a project with similar queries that fetch not all the same data?
E.g. Query A retrieves an Author and a count of all the boks he has written. Query B retrieves an author and the title of the most recent book he has written. I see following options:
- make two models, one for each query -> leads to a lot of similar models and code-bloat
- make a base query and fetch additional data with an additional query -> leads to a lot of small queries that would sometimes be more performant as a single query
E.g. Query A retrieves an Author and a count of all the boks he has written. Query B retrieves an author and the title of the most recent book he has written. I see following options: - make two models, one for each query -> leads to a lot of similar models and code-bloat - make a base query and fetch additional data with an additional query -> leads to a lot of small queries that would sometimes be more performant as a single query