Select top row for each group

select top row for each group

Is this possible in HQL??

Where I can receive the output in a list of the DTO class, without any cast exception

It’s not clear what you are asking. Try to provide an example and provide more details so we can get a better understanding of your problem.