-->
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: Problem ordering-by a many to one
PostPosted: Tue Apr 19, 2005 4:00 am 
Newbie

Joined: Mon Dec 27, 2004 2:52 pm
Posts: 6
Hi,

I'm using hibernate 2.1.7 and i've got some problems ordering a table.
This is my mapping:

<class name="User" table="users">
<id name="id" column="usr_userid" type="int" unsaved-value="null">
<generator class="assigned" />
</id>
<property name="language" column="usrlan" type="string" />
...
<many-to-one name="client" column="usr_idclie"
class="Client" cascade="none" update="false"
insert="false"/>
</class>

I need to get all users, ordered by fullName, which is a Client field

So, i do :

session.query (" from User user order by user.client.fullName desc ");

But my problem is :

it doesn't return all the rows, only those whose client field (usr_idclie) is filled, but i need all the users, what i'm doing wrong ? May be is bad - mapped ?

Can anybody help me please?

Thanks for advanced.


Top
 Profile  
 
 Post subject: help please
PostPosted: Wed Apr 20, 2005 11:21 am 
Newbie

Joined: Mon Dec 27, 2004 2:52 pm
Posts: 6
I did another test

I tried to get All users ordered by id (it's the key) instead of fullName.

session.query (" from User user order by user.client.id desc ");

and i got all the entries, it means, users with client and users without client, well-ordered by id.

However, if i do the same, ordered by another field, for example, fullName,
it doesn't work succesfully. It retrieves only the users with client. not ALL.


Please, can any body help me ? or suggest me any idea?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 21, 2005 5:29 am 
Beginner
Beginner

Joined: Wed Apr 21, 2004 8:33 am
Posts: 27
Hi Salino
You can try giving OrderBy in the mapping where you defined.
OrderBy column name , Asc/Desc

just check out the syntax i dont remember

Thanks


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.