Re: Large Data - How to Do Paging in ActiveJDBC (and how to extend into standard REST calls?)

92 views
Skip to first unread message

Igor Polevoy

unread,
Dec 14, 2014, 1:22:53 AM12/14/14
to activejd...@googlegroups.com
Gianna, paging of course is supported in ActiveJDBC.
For instance, on the AJ page there is this example: http://javalite.io/activejdbc#paging-through-data

There is a class specifically built for paging: http://javalite.github.io/activejdbc/org/javalite/activejdbc/Paginator.html

There is a paging example in the Kitchensink project: https://github.com/javalite/kitchensink/blob/master/src/main/java/app/controllers/PeopleController.java
So, with only 20000 records you can use any of these methods.

When you start hitting millions, your DB will slow down and I recommend implementing what other big services do. For instance Twitter API uses since_id and max_id:
https://dev.twitter.com/rest/reference/get/search/tweets

I hope it helps

igor


On 12/13/2014 11:24 PM, Gianna Giavelli wrote:
p.s. in hibernate its done as:
  Query q = session.createQuery("...");
q.setFirstResult(start);
q.setMaxResults(length);

On Saturday, December 13, 2014 11:18:54 PM UTC-6, Gianna Giavelli wrote:

One of the main things I do is something like 
   "get all books"

But when there are 20,000 books, I usually pass in a page size and a page number. 

   "get all books from 201 to 220"

I don't see any calls to support paging in ActiveJDBC, but I know there are some issues with jdbc drivers and paging support but even if we have to manually walk the result set it would be good if there were conventions for how to send paging parameters along with REST requests. usually you send a page number, and a page size.

Here is how spring does it:

@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
  config.setPageParamName("p")
        .setLimitParamName("l")
        .setSortParamName("q");
}

The URL to use these parameters would then be changed to:

http://localhost:8080/people/?p=2&l=50
--
You received this message because you are subscribed to the Google Groups "ActiveJDBC Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activejdbc-gro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gianna Giavelli

unread,
Dec 14, 2014, 3:13:23 PM12/14/14
to activejd...@googlegroups.com
Sorry Igor, I tried to delete this. Yes I got the paging working. it seems when I post, I am close on the hunt! 

I have a neat solution. I will post it once its all there. Is there some place I can share a code sample with you?

Igor Polevoy

unread,
Dec 14, 2014, 4:16:59 PM12/14/14
to activejd...@googlegroups.com
I will be adding a blog to javalite.io site, and will be inviting posts there from community. I think it will be a perfect place for this. 
I'm working on a new version of the site, and will roll it in the next few days. 
Let me know when  you are ready, and I will post it there. 

thanks
Reply all
Reply to author
Forward
0 new messages