torpedoquery
torpedoquery copied to clipboard
Project the results to a specific class
Hi.
Congratulations for your work, with your solution I need to write less code than other alternatives like Querydsl, besides do not generate intermediate classes.
However I miss some features like fetch joins or being able to project the results to a specific class. Something like this:
Entity entity = from(Entity.class); SubEntity subEntity = innerJoin(entity.getSubEntity());
List[MixEntityDTO] listDTOs = select (create (MixEntityDTO.class, entity.getCode(), subEntity.getCode()).list (entityManager);
PD. I put [ ] in listDTOs definition because the simbols: less and major causes the code in between these characters not see.
Thanks in advance.
Thanks for the feedback. It will be easy to add fetch join I think the better way to do it is like that SubEntity subEntity = fetch(innerJoin(entity.getSubEntity()));
And to create new objects I will check how I can do it I will try to keep the type safety " new MixEntityDTO(entity.getCode(), subEntity.getCode()) "
Hi xjodoin
fetch perhaps could be an extra parameter in "join functions". On the other hand, I prefer your solution when projecting the results to a particular class.
I'll be awaiting the new version to be able to integrate it into my projects.
Thanks and good work.