torpedoquery icon indicating copy to clipboard operation
torpedoquery copied to clipboard

Project the results to a specific class

Open doctore opened this issue 10 years ago • 2 comments

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.

doctore avatar Mar 29 '14 09:03 doctore

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()) "

xjodoin avatar Mar 31 '14 12:03 xjodoin

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.

doctore avatar May 19 '14 09:05 doctore