-->
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 in one to many relation
PostPosted: Thu May 27, 2010 10:09 pm 
Newbie

Joined: Thu May 27, 2010 8:36 am
Posts: 1
Dear all,
I'll be thankful to you if you can save me from this problem. 1st of all I'm a very beginner in Hibernate and JPA.
I've 3 tables A, B and C. A has columns a1 (primary key),a2 and a3. B has b1, b2, b3, a1 and c1. C has also the same. Table A has one to many relationship to B and it is mapped by 'a1'. B has relation to C and is mapped by c1. a1 and c1 are foreign keys in B. Finally I want to create a list of 'c2'.
I got the list in the order of the contents that are in the table itself. Is there any way to sort the list using any other columns in all the tables? Also it should be using an annotation at the time of one to many declaration. Pls do the needful.


Pls reply a solution as early as possible...

Thanx.


Top
 Profile  
 
 Post subject: Re: Sorting in one to many relation
PostPosted: Fri May 28, 2010 2:54 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Hibernate has two custom annotations that you can use for sorting: @OrderBy and @Sort. With @OrderBy the collection is sorted in the database and with @Sort it is sorted in memory. See http://docs.jboss.org/hibernate/stable/ ... collection for more information.


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.