-->
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: Criteria and order by concat
PostPosted: Sun Sep 10, 2006 1:40 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
Hibernate version:3.1.2
Name and version of the database you are using: Oracle9

Hello,

If you want to

1- Fetch object using Criteria API and pagination
2- Use complex order by (containing concat(a,b))

You have to

1- define you own Projection class
2- run Criteria.list to order your result using your Projection, apply pagination and get the PKs
3- run Criteria.list to load the Object based on their PKs

Am I right or did I miss the point ?

Ideally I would like to use a Criteria with some criterions to fetch persistent object AND order them using SQL "concat".
I understand that even in Oracle you have to include the concat in the select clause to be able to use it for ordering the results.

Thanks

_________________
Denis
Don't forget to rate ... thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 10, 2006 5:47 pm 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
I've got two solutions:

    define a calculation property (using formula) for your complex sort, and sort ont it!
    extend the Order class, so the derived class can handle complex sortings


-----------------
don't forget credits

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 11, 2006 3:37 am 
Regular
Regular

Joined: Fri Aug 18, 2006 2:40 pm
Posts: 51
Location: Metz, France
I didn't know anything about formula. Looks very convenient.

Subclassing Order is a great idea too.

Thanks a lot for your suggestions.

_________________
Denis
Don't forget to rate ... 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.