I don't think you can achieve it using one JPQL query. Perhaps, if native query would be used you might achieve it (not sure, tho).
I don't think you can achieve it using one JPQL query. Perhaps, if native query would be used you might achieve it (not sure, tho). Consider splitting the problem into two parts: invoke a query which returns the statistics but without authors, for each returned row, fetch the authors.So firstly invoke such query: SELECT DISTINCT COUNT(wl.
BookTitle) AS POP, wl. BookTitle, wl. BookCattegory, MAX(wl.
Id) FROM WishList wl GROUP BY wl. BookTitle, wl. BookCattegory, wl.
AuthorList ORDER BY POP DESC According to the query, each returned row will have the same authors. The MAX(wl.Id) is used just to get one of these ids you can query for the authors list. Having this id you can for each record fetch the authors and return such prepared data (popularity, book title, category, authors).
It'll surely not get the highest ranks in the performance category as doing it in one query, I don't see other solution at this point.By the way - are you sure your model is OK? Each WishList have exactly one book title, category and authors? Shouldn't the book data be separated to a Book entity and each WishList consists of many Books?
I think it then should be easier to query for WishLists which consists of the same books.
Thanks for your response. I will try to make it in two separate queries. (In my model I have entity named Book - but it is for other purposes) – problemgenerator Dec 5 at 11:51.
I don't think you can group by a ManyToMany, try, SELECT Count(wl. BookTitle) AS POP, wl. BookTitle, wl.
BookCattegory, a. Id FROM WishList wl join wl. AuthorList a GROUP BY wl.
BookTitle, wl. BookCattegory, a. Id ORDER BY POP DESC.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.