Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problems to use order by a null association(Jpql doesn't return the entities with nulls)
icon5.gif  Problems to use order by a null association [message #610099] Tue, 21 September 2010 20:56 Go to next message
No real name is currently offline No real name
Messages: 7
Registered: April 2010
Junior Member
Hello all!

I have two entities, A and B. A has manyToOne association with B. To list all A's ordered by B's in native sql I use this:

select * from A order by fk_idB

* fk_idB is the foreign key

But in jpql I use:

select a from A a order by a.b.idB

But now only the A's that has a B entity are returned. I need to return all A's! How I can do this?

Please someone help me!
Thanks
Re: Problems to use order by a null association [message #628629 is a reply to message #610099] Thu, 23 September 2010 13:38 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
Hello,

The JPQL "select a from A order by a.b" might work as I believe EclipseLink has optimizations in place to just use the foriegn key. But the spec implies that using a '.' for a relationship should cause an inner join. So to be sure an outer join is used (for instance, if A doesn't have the foreign key), you may want to specify an outer join be used. For example:
"select a from A a outer join a.b b order by b"

Best Regards,
Chris
Previous Topic:How can I associate primary and secondary tables with a join criteria other than the compound key
Next Topic:Chain of eager relationships
Goto Forum:
  


Current Time: Fri Oct 24 21:31:01 GMT 2014

Powered by FUDForum. Page generated in 0.02432 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software