-->
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.  [ 2 posts ] 
Author Message
 Post subject: Sorting "sub" criteria
PostPosted: Tue May 27, 2008 4:22 pm 
Newbie

Joined: Tue May 27, 2008 4:13 pm
Posts: 1
i am pulling information from two tables. i have the two tables joined and now i need to sort first based off of an integer in "table2" and then by an integer in "table1". the following code works for me, but there is no sorting involved. any help would be appreciated.

Code:
return getSession().createCriteria(getModelClass())
      .setFetchMode("adapterInstances", FetchMode.JOIN)
      .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
      .list();


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 28, 2008 9:45 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Why not just throw in a few Order commands.

Image

Quote:
An Order object is created by using one of the two static methods in the Order class, namely the static asc(String) and desc(String) methods. Basically, you just chose whether you want your list to be sorted in ascending order, or descending order, and pass to the appropriate method the name of the field on which you want to sort.

Order order = Order.asc("loginName");

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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