I have two class book and reader, using one to many relationships between book and reader. I want to retrieve all record from book and latest matching record from reader. Using spring data jpa
@Query(“select b from book b left join b.reader r on r.id=(select r.id from b.reader where r.bookId=b.bookId order by r.date desc limit 1)”)
I have written custo query in Jpa Repository. But it’ s given all record form reader table not latest
user25234940 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.