-->
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: two sort orders in the same query
PostPosted: Wed Dec 04, 2013 9:26 am 
Newbie

Joined: Wed Nov 27, 2013 1:53 am
Posts: 6
Hi,
One of my project table contains the below like columns:

EmployeeId EmployeeName EmployeeCreatedDate
1 jana 2012-12-12 00:00:00.000
2 gana 2012-12-04 00:00:00.000

I have a requirement like below:

The list should show the top 200 employees based on the EmployeeCreatedDate desc.
The output of the above top 200 employees should be in alphabetical order based on employeename.

How to achieve the above two order by's in hibernate in single query or with single Criteria or with any other mode of queries?

select * from employees order by EmployeeCreatedDate desc, EmployeeName didn't work, as usual...


Top
 Profile  
 
 Post subject: Re: two sort orders in the same query
PostPosted: Fri Dec 06, 2013 6:39 am 
Newbie

Joined: Wed Nov 27, 2013 1:53 am
Posts: 6
Is anybody there to help me in this regard?


Top
 Profile  
 
 Post subject: Re: two sort orders in the same query
PostPosted: Fri Dec 06, 2013 12:19 pm 
Newbie

Joined: Fri Dec 06, 2013 11:04 am
Posts: 6
At least for me was working using nativequery and puting the name of the table like this.

select * from employees e order by e.EmployeeCreatedDate desc, e.EmployeeName desc


ghvijayakumar wrote:
Hi,
One of my project table contains the below like columns:

EmployeeId EmployeeName EmployeeCreatedDate
1 jana 2012-12-12 00:00:00.000
2 gana 2012-12-04 00:00:00.000

I have a requirement like below:

The list should show the top 200 employees based on the EmployeeCreatedDate desc.
The output of the above top 200 employees should be in alphabetical order based on employeename.

How to achieve the above two order by's in hibernate in single query or with single Criteria or with any other mode of queries?

select * from employees order by EmployeeCreatedDate desc, EmployeeName didn't work, as usual...


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.