File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes [JPA, TopLink] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "[JPA, TopLink] "Resursive" fetch join" Watch "[JPA, TopLink] "Resursive" fetch join" New topic
Author

[JPA, TopLink] "Resursive" fetch join

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
Hi. I am currently learning EJB3, and time has come to get the hang of JPQL. I have two persistence units, one uses TopLink Essentials (default for GlassFish, the application server I am using), and the other one is Hibernate EntityManager.
I hava a Category class, that has a one-to-many mapping to itself. That is, a Category has a parent, and a category has many subcategories. With Hibernate, it is possible to "recursively" fetch parents. For example, Category A has a Subcategory B, which has Subcategory C. This query returns the whole hierarchy starting with C, going upward:

I can also use

which TopLink refuses to process even for one fetch join, as there is an alias specified for the fetch property.
So my question is, can this be done in Toplink? Or is it one limitation of JPA altogether, to allow only one level of fetch joins?
Thanks.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
The JPA 1.0 JPQL specification does not allow an alias or nested fetch joins.

TopLink Essentials, or at least EclipseLink (Glassfish v3) support nested fetch joins through a query hint "eclipselink.join-fetch".

Feel free to log an enhancement request for the JPQL extension for EclipseLink on Bugzilla.
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [JPA, TopLink] "Resursive" fetch join
 
Similar Threads
TransientObjectException: object references an unsaved transient instance
self referencing relationship - many selects from hibernate
Conditions for dependent entites on fetching?
JPA - getSingleResult Error
How to display only selected amount of data from database in two dropdown lists?