-->
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: Fetching user posts with pagination
PostPosted: Wed Aug 19, 2015 11:19 am 
Newbie

Joined: Wed Aug 19, 2015 11:12 am
Posts: 1
I have a user table & a child table Post containing user's posts. A user has a large number of posts just like twitter posts.

I need to fetch user posts on the UI, load more posts as the user scrolls down the page just like facebook/twitter do. I am using hibernate as the ORM framework & MySql as db. I looked into pagination found two primary ways of achieving that

Code:
1. setFirstResult();
   setMaxResults();

2. ScrollableResults


I have two questions

A. Which way of pagination would be more appropriate & efficient to achieve this? I've read that ScrollableResults is more efficient than setFirstResult but it keeps the connection open for the entire pagination process.

B. As the user's profile page is loaded ajax call is fired to display the user's posts everytime, it's like a certain default content in the page. So do I need to implement a second level cache in order to avoid db hits every time the page loads?


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.