Loading...
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
TUTORIAL

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

JPAContainer - how to limit records found

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

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

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