Create new Object In JPQL Select Statement by Constructor Expression
When you want to retrieve a Data Transfer Object instead of retrieving a full entity or a full graph of objects in a type safe way, then you can create the new Object in the JPQL select statement:
Here a constructor is used in the SELECT list to return one or more Java instances. The constructor name NEW . . . ( . , . ) User u;must be fully qualified.