openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Is INNER JOIN necessary with ORDER BY?
Date Wed, 26 Mar 2008 19:11:39 GMT
Hi Ognjen,

As I understand the JPA specification, your analysis and solution are  
correct. By the specification, navigating a relationship uses inner  
join semantics.

By the way, JDO uses outer join semantics in query navigation. With  
JDO, you would get Persons with null id_place_of_birth unless your  
query explicitly had a query clause id_place_of_birth != null. Of  
course, the position of the null entries in the result list still  
might be before or after non-null entries.

Regards,

Craig

On Mar 26, 2008, at 5:14 AM, Ognjen Blagojevic wrote:

> Hi all,
>
> How can I avoid INNER JOINs to be generated for tables stated in  
> ORDER BY clause?
>
> For instance, EJB QL
>
>  select p
>    from Person p
>   order by p.idPlaceOfBirth.name
>
> results in SQL which INNER JOINS Person and Place, and the persons  
> without known place of birth (id_place_of_birth == null), are not  
> listed.
>
> The only solution I found so far is to explicitly use
>
>  select p
>    from Person LEFT OUTER JOIN p.idPlaceOfBirth b
>   order by p.idPlaceOfBirth.name
>
> But it tends to unnecessarily add to the EJB QL queries complexity.
>
> Is there any other way to do the same thing?
>
> Regards,
> Ognjen

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message