我正在努力弄清 HQL ,并在IntelliJ IDEA的Persistence窗口中运行它。
这就是问题:我可以运行像这样的简单查询:
hql> SELECT offer FROM OfferEntit offer;
hql> SELECT offer FROM OfferEntit offer WHERE offer.id = 1L;
但是如果我添加类似JOIN
的内容:
hql> SELECT offer FROM OfferEntit offer
JOIN offer.owner AS owner WHERE owner.id = 1L;
我得到一个空结果。总是。不管我做什么。我不知道为什么。
也
答案 0 :(得分:0)
您可以尝试左联接还是联接提取
SELECT offer FROM OfferEntit offer
LEFT JOIN offer.owner AS owner WHERE owner.id = 1L
SELECT offer FROM OfferEntit offer
JOIN FETCH offer.owner AS owner WHERE owner.id = 1L