可编写如下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=?
本文介绍了一种使用HQL进行联表查询的方法,并给出了相应的SQL转换示例。通过一个具体的例子展示了如何在HQL中实现基于元素的关联查询,并详细解释了其转换为SQL后的执行逻辑。
4491

被折叠的 条评论
为什么被折叠?



