currently I am working with JPQL to create an BookRepository.
My data structure looks like this:
Now I want to find the book, that have no quotes in the last 10% of the pages. My problem is that my program always compares ALL quotes, but I only need the last one to compare.
This is my JPQL:
@Query("SELECT DISTINCT b FROM Book b, Chapter c, Quote q JOIN b.chapters c JOIN c.quotes q WHERE q.pageNumber < (b.pageNumber * 0.9) AND q ORDER BY b.title")
Thank you for your help!
您可以编辑您的 where 子句,如下所示:
WHERE NOT EXISTS (SELECT * FROM q WHERE q.bookId=b.id AND q.pageNumber>(b.pageNumber * 0.9))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.