-->
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.  [ 1 post ] 
Author Message
 Post subject: How to order by joined object, e.g entity.createdBy.lastName
PostPosted: Wed Nov 19, 2008 9:51 pm 
Newbie

Joined: Tue Jan 16, 2007 3:44 pm
Posts: 10
Hi all,

I have been wondering how to order by a joined object, e.g. an project creator's lastName. Now, I got an idea, but I am not sure whether it is good or not, or maybe somebody has a better one. Welcome other people to share. Thanks in advance. Following is my sql and entity classes:
Code:
"select new Project (creator, project)
from Project project
inner join project.createdBy creator
order by creator.lastName"


@Entity
public class Project {
   ...
   private Person createdBy;
   
   public Project (Person createdBy, Project project) {
       ...
       this.createdBy = createdBy;
       ...
   }
   ....
}

@Entity
public class Person {
   ...
   private String lastName;
   ...
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.