QueryDSL 显式连接和 where 子句之间的区别?

QueryDSL difference between explicit join and where clause?

假设您有如下 QueryDSL 查询:

JPQLQuery query = new JPAQuery(em);
QUser user = QUser.user;
QLocation location= QLocation.location;

query.from(User).innerJoin(user.location, location).where(user.name.eq("Giuseppe").and(location.name.eq("Vatican City")));

这与以下内容(在功能上)有何不同?

JPQLQuery query = new JPAQuery(em);
QUser user = QUser.user;

query.from(User).where(user.name.eq("Giuseppe").and(user.location.name.eq("Vatican City")));

在我看来,两者都能够解决用户所在位置必须是梵蒂冈城的条件。此外,两个 return 对象都允许在对象图中导航。

所以有什么区别吗?为什么不只使用第二个,更紧凑的一个?

编辑: 他们生成不同的 JPQL,这是肯定的,但我不确定最终结果是否有任何不同。为什么我们要明确列出我们正在做的连接?

编辑 2:看起来它们可能是相同的...http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch11.html#d5e2888

郑重声明,where 子句中的隐式连接执行内部连接。 According to the QueryDSL forum,当您想要重用联接或使用除内部联接之外的其他联接类型时,您会使用显式联接。否则,您可以只使用 where 子句。