-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Order by ignores null values
PostPosted: Mon Dec 17, 2007 6:58 am 
Newbie

Joined: Mon Dec 17, 2007 6:39 am
Posts: 1
Location: Estonia
from Product s order by s.producer.name asc

The query returns 0 results because all the products have no producers. Basicly it doesn't order there null values. It doesn't even return them.

How can I get it to return these products that have no producer?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 17, 2007 7:20 am 
Regular
Regular

Joined: Sat Nov 25, 2006 11:37 am
Posts: 72
Option 1: Remove the order by clause to prevent Hibernate from retrieving producers

Option 2: Use a left outer join, similar to
select s, p from Product s left outer join Producer p on s.<fk> = p.<pk> order by p.name


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.