Heys guys, i have a Problem using Play Framework. I am trying to display a large amount of Data (from this Database). When i am using the "find.all()" the Play Framework Server crashes, since it takes to much memory.
I got a DB Model named:
@Entity
public class dblp_pub_new extends Model {
[...]
public dblp_pub_new() {}
public static List<dblp_pub_new> all() {
return find.all();
}
public String getDoi() {
return doi;
}
public void setMdate() {
this.mdate = new Date();
}
public static Finder<String,dblp_pub_new> find = new Finder<String, dblp_pub_new>(String.class, dblp_pub_new.class);
}
My rendering function is, which is contained in Application.java:
public static Result dois(){
return ok(views.html.index.render(dblp_pub_new.all(), DoiForm));
}
I am trying to limit the all() Query to 50 (best would be per page). But i cant seem to figure it out. I think i need a List returned to display it on the webpage. But I can't get it to work. I would be really relieved if one of you guys (and girls) could help me figuring out this problem. I've tried it with "fetch" and "setMaxRows()" but I only get errors i can't seem to solve. If there is something unclear, please just ask and i will try to provide as much information as i can. Thank you.
Ebean has a helper for making pagination of data easier. It's called a PagingList
there. Play's Finder
helper class for Ebeans allows you to get such a PagingList
for your query.
Say you want to display 50 items per page, and want to retrieve the items for the first page. Then you'd write something like this
public static List<dblp_pub_new> getpageItems(int page) {
int pageSize = 50;
return find.findPagingList(pageSize).getPage(page).getList();
}
Also, please note that your class name dblp_pub_new
is highly unusual. Refer to this question for more information.