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.  [ 4 posts ] 
Author Message
 Post subject: Complex sorting with criteria api
PostPosted: Tue Jun 06, 2006 4:29 pm 
Newbie

Joined: Tue Jun 06, 2006 3:57 pm
Posts: 2
Hi,

I am using criteria api for search functionality in my application. I am stuck due to some sorting issues.

I have a project object which has a collection of team members. Team members are assigned different roles like Architect, Lead, Programmer, etc and presence of any role is not mandatory. A project may or may not have team members.

In search results I am displaying the Architect's name (if any) along with other properties of project. Now I want to sort the result (list of project objects) on the basis of Architect's name.

I think I can achieve this through HQL but I would like to do this using criteria api. I'll appreciate any help.

thanks
rohit


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 07, 2006 1:57 pm 
Beginner
Beginner

Joined: Fri May 26, 2006 7:15 am
Posts: 20
Location: Vandavasi, TamilNadu
try this,

List projectList = session.createCriteria(Project.class)
.createAlias("tblMember","member")
.addOrder(Order.asc("member.name")).list()


if not working, post with ur mappings and xml files


thanks

_________________
gajini
------------------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 2:04 am 
Newbie

Joined: Tue Jun 06, 2006 3:57 pm
Posts: 2
thanks for reponse.

This will not work for following reasons:

1. A project may or may not have team members, hence the join need to be a outer join (which I think is possible to create after a bug fix in 3.1).

2. I need to sort results on the basis of Architect's name and a project's team will have members other than Architect. Solution will sort the result on the basis of name of all members.


thanks
rohit


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 3:48 am 
Beginner
Beginner

Joined: Fri May 26, 2006 7:15 am
Posts: 20
Location: Vandavasi, TamilNadu
can u post with table desc(with sample records) and
sample result u like to have ?

_________________
gajini
------------------


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