-->
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: what type should I use if I need to do paging of data?
PostPosted: Tue Mar 16, 2004 3:20 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
im a little confused as to what type should I use if I need to do paging of data.

things I need to do are typical previous row/next row paging and also previous 50 rows/next 50 rows paging

i've been using set all along, but then I read that Sets were not ordered

then with further reading it mentioned using order-by with jdk 1.4 would order the sets, so my question is, can I convert that set to a list (by passing the Set into ArrayList constructor and everything will still be ordered?


or am i totally doing this wrong?

I just need some feedback here so I do go off on a wild tangent..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 3:33 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
Check this out... it talks about using a comparator to order collections. http://www.hibernate.org/hib_docs/reference/html/collections.html#collections-s1-8a

This is how we do paging / navigatable list.
NOTE: the query String could have and probably would have an "order by" clause at the end of it.
Code:
Query q = session.createQuery(query);
q.setMaxResults(maxRecordsPerPage);
q.setFirstResult(((pageNum - 1) * maxRecordsPerPage));

List list = q.list();


hope this helped :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 10:33 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
excellent, that did the trick!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 11:34 pm 
Newbie

Joined: Mon Nov 17, 2003 3:50 pm
Posts: 19
Do you know how I can get the previous and next row given the current row? Example, let's say I want to get 1row by a criteria. Now I have this row, I would like to get the previous and next row from this one. How would I do this?

Thanks!

tcollins wrote:
Check this out... it talks about using a comparator to order collections. http://www.hibernate.org/hib_docs/reference/html/collections.html#collections-s1-8a

This is how we do paging / navigatable list.
NOTE: the query String could have and probably would have an "order by" clause at the end of it.
Code:
Query q = session.createQuery(query);
q.setMaxResults(maxRecordsPerPage);
q.setFirstResult(((pageNum - 1) * maxRecordsPerPage));

List list = q.list();


hope this helped :)


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.