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.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

JPAContainer - how to limit records found

Pietro Marrone
1 decade ago Jan 17, 2012 1:49pm
Matti Tahvonen
1 decade ago Jan 17, 2012 2:23pm


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()) {
			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.


Pietro Marrone
1 decade ago Jan 18, 2012 2:35pm
Jacob Boswell
1 decade ago Jul 19, 2012 9:33pm