English 中文(简体)
玻璃鱼Eclipselink联合获取提示无效。
原标题:
  • 时间:2009-02-26 15:45:07
  •  标签:

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.

有没有其他人也遇到这个问题...还是只有我呢 :-(

任何帮助或提示(无任何恶意)将不胜感激。

最佳回答

好的,在8个小时的挫折后,我终于找到了问题的根源。

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

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.

问题回答

暂无回答




相关问题
热门标签