Currently, I am fetching all the columns and then use MapStruct to map it into the DTO, it works fine for me.
It is bothersome to just select several fields in Hibernate/HQL.
select forum.id, forum.name, forum.lastThread from Forum forum", I need to use
setResultTransformerwhich is deprecated in Hibernate 5.2
select new (...) from ...will make my query a big mess, and idk whether it allows nested new.
Spring Data JPA Projection will still fetch all columns of the joined enity (https://stackoverflow.com/questions/40194614/spring-data-jpa-projection-selected-fields-from-the-db#comment89435552_40194614)
So I think I should just stick with the old way (select the whole enity and use MapStruct).
I want to know is there any big gap about the performance between between these two, especially in the case my queries contains several join statement