Even when DTO is separate, you can use projection methods of eg: spring data JPA, or something like mapstruct.