Glassfish Eclipselink join-fetch 提示不起作用

发布于 2024-07-14 09:37:24 字数 769 浏览 7 评论 0原文

我很难让 eclipselink.join-fetch 提示在 glassfish 中工作。

我有一个 Client 对象,其中包含 Task 对象的集合,而 Task 对象具有 WorkPeriod 对象的集合。

我的代码如下所示:

Query query = entityManager.createQuery("select client from Client client left join fetch client.tasks");   
//Set hint to allow nested fetch joins
query.setHint("eclipselink.join-fetch","client.tasks.workPeriods");
List<Client> clients = query.getResultList();

但是,当我将 TOPLINK 调试级别设置为fine 时,无论我做什么,它总是显示实际运行的 SQL 是:

SELECT t0.ID, t0.NAME, t1.ID, t1.DESCRIPTION FROM CLIENT t0 LEFT OUTER JOIN (CLIENT_TASK t2 JOIN TASK t1 ON (t1.ID = t2.tasks_ID)) ON (t2.Client_ID = t0.ID)

显然没有执行连接获取的第三层。

有其他人遇到这个问题吗...或者只是我:-(

任何帮助或提示(没有双关语)将不胜感激。

I'm having real difficulty getting the eclipselink.join-fetch hint to work in glassfish.

I have a Client object that contains a collection of Task objects and the Task object has a collection of WorkPeriod objects.

My code looks like this:

Query query = entityManager.createQuery("select client from Client client left join fetch client.tasks");   
//Set hint to allow nested fetch joins
query.setHint("eclipselink.join-fetch","client.tasks.workPeriods");
List<Client> clients = query.getResultList();

But no matter what I do when I set the TOPLINK debug level to fine it always shows that the SQL which is actually run is:

SELECT t0.ID, t0.NAME, t1.ID, t1.DESCRIPTION FROM CLIENT t0 LEFT OUTER JOIN (CLIENT_TASK t2 JOIN TASK t1 ON (t1.ID = t2.tasks_ID)) ON (t2.Client_ID = t0.ID)

Clearly not doing the third tier of the join fetch.

Has anyone else had problems with this... or is it just me :-(

Any help or hints (no pun intended) would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半衾梦 2024-07-21 09:37:24

好吧,经过 8 个小时的沮丧之后,我已经找到了真相。

Glassfish V2 不使用 EclipseLink 作为其持久性提供程序,而是使用 Toplink Essentials。 不幸的是,Toplink Essentials 没有提供 join-fetch 提示(我对以下链接感到非常困惑,这让我认为它确实提供了: https://glassfish.dev.java.net/issues/show_bug.cgi?id=1200 虽然这显然是一个功能请求而不是一个功能)。

因此,看来我尝试做的事情是不可能的,如果我想在 glassfish 中进行多级急切获取,我将必须获取 EntityManagers 委托并直接使用 toplink Essentials 表达式。

OK, after 8 hours of frustration I've got to the bottom of it.

Glassfish V2 doesn't use EclipseLink as it's persistence provider, it uses Toplink Essentitals. Unfortunately Toplink essentials doesn't provide a join-fetch hint (I was very confused by the following link which made me think it did: https://glassfish.dev.java.net/issues/show_bug.cgi?id=1200 although this is obviously a feature request NOT a feature).

So it would appear that what I'm attempting to do is not possible and if I want to do multi-level eager fetch in glassfish I'm going to have to get the EntityManagers delegate and use the toplink essentials Expressions directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文