hql 多對多查詢 elements
可編寫如下Hql 語句完成查詢:
- 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=?