-->
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.  [ 3 posts ] 
Author Message
 Post subject: Order by null values
PostPosted: Tue Mar 07, 2006 7:06 am 
Newbie

Joined: Mon Feb 06, 2006 8:53 am
Posts: 7
Location: Antwerp Belgium
Hi All

I have a problem with sorting in Hibernate.

I have a collections of documents with an User attached to it. The User can have a null value.

When I ask all documents (select * from documents) all documents are returned, also the one with no User.

When I sort on User (Order by documents.User) I only get the ones where user is not null

How can I sort on user and retrieve all the documents


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 4:49 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try this:
Code:
select document from Document document left join document.User user order by user

(or order by user.id)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 5:56 pm 
Newbie

Joined: Mon Feb 06, 2006 8:53 am
Posts: 7
Location: Antwerp Belgium
It works, I added left join fetch to retrieve only the documents.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.