可编写如下Hql 语句完成查询:
- select Blog
- from Blog, Book
- where Blog.author in elements(Book.authors)
- and Book.id=?
select Blog
from Blog, Book
where Blog.author in elements(Book.authors)
and Book.id=?
对应的Sql近似如下:
- select blog.*
- from blog, book
- where (blog.author in ( select author.authorid
- from book_author
- where book.id=book_author.bookid))
- and book.id=?