As shown in query and result, I want to fetch and add the result in list but how do I do it in Spring data. How to hold the result in a list?
Should I create a new entity class? Keeping in mind that I absolutely do not need to map my model class to database. I simple want to fetch and use the list in controller.
Thanks to anyone who can help.
You can use projections.
In your case, for example:
Then use it in your query method:
Pay attention on aliases in the query - they must correspond to projection method names (i.e.
total
->getTotal()
...).