The issue of DTO projection return type

Where is the source code for HIBERNATE ORM to parse hql into select expressions? I have a question that I am very confused about. When I use immutable class to query, it is normal to query. But when I use mutable class, I need to convert them.
I am using JPA and HIBERNATE
ImmutableDTO immutableDTO = repository.findById(int id);
NormalDTO normalDTO = repository.findById(int id);


The query of immutable class will be executed to this position .
So please tell me the parsing rules for expressions or whether there is any processing done for immutable class DTO Projection or interface DTO Projection during parsing

You can find Hibernate’s source code here: GitHub - hibernate/hibernate-orm: Hibernate's core Object/Relational Mapping functionality.

Query parsing and return type interpretation is a major component of Hibernate ORM’s logic, so we can not simply “tell you the parsing rules for expressions”. If you need help, please formulate specific questions and give us more context to understand what you’re trying to achieve.