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

It Worked Thanks

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?