I have a Base entity with a many-to-one relationship with a Nested object. I want to order a request at Nested.name, where the name can be null. Even if the name is null, I want the query to return this string. So I'm trying to get EclipseLink to generate queries that have LEFT JOINs together, instead of selecting from both tables.
I annotated the relationship between the base and the nested with the @JoinFetch annotation as follows:
@ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "BASE_ID") @JoinFetch(value = JoinFetchType.OUTER) private Nested nested;
However, this does not seem to have any effect on requests created by EclipseLink. Actual generated request
SELECT ... FROM BASE t0, NESTED t1 WHERE (t1.ID = t0.BASE_ID) ORDER BY t1.NAME ASC...
while I expect something along the lines
SELECT ... FROM BASE t0 LEFT JOIN NESTED t1 ON (t1.ID = t0.BASE_ID) ORDER BY t1.NAME ASC...
I use the JPA 2.0 criteria API to create and execute queries. Even if I explicitly create a join query using the criteria API, the resulting query will look like the first, without joins. Explicit joining when building a query seems to work fine with Hibernate, but does not affect the resulting query in EclipseLink.
I probably have something missing, so any advice is welcome.
thanks
source share