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.
posted 7 years ago
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".