Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JPAContainer - how to limit records found
is it possible limit the record found on a JPAContainer or at list on a table.
What I'd like to have is to show tha last "n" records inserted
Regards
Hi,
I tried just to quickly limit what the size method returns and it seams to work pretty well. Here is a snippet of my test app:
container = new JPAContainer<T>(getEntityClass()) {
@Override
public int size() {
int size = super.size();
if(size > 4) {
return 4;
}
return size;
}
};
In addition to that you probably also want to sort your container descending on id or a timestamp. There you could use the Vaadin Container.Sortable API or the QueryModifierDelegate class to modify the built query directly with JPA Criteria API.
cheers,
matti
Does this still pull the whole data set? I have a large table and set the count to 4, but it seems to be very slow.
Really my question is does this boil it down to the JPA or DB query level, or still pull a big set, then limit that set in the display?