JPA Best Practices Webinar

Join Vaadin’s Thomas Mattsson and Matti Tahvonen to get more familiar with JPA. Everything from Deltaspike to pure JPA and how to use it with Vaadin for binding your data to your UI and the other way around. This is both an introduction as well as a best practices webinar.Post your questions beforehand below.

The webinar takes place on December 17th 2015 @ 2PM CET

embedyoutube=f1VD3y2PWZs

Is there going to be continued support for JPAContainer? (asking because nothing seems to have happened there recently and it is still usefull for small CRUD projects after all)

The example project we used in the webinar is available on github:
https://github.com/mstahv/jpa-addressbook

Daniel, there are currently no big plans for JPAContainer, but it is still maintained if there are some critical bugs in it. Instead we are planning to come up with lazy loading solutions and improved basic data binding to core components, same sort of stuff that there is in Viritin add-on. And BTW, the setup we repsented in this webinar (EJB, DeltaSpikeData + Viritin for lazy loading) is pretty efficient for small CRUD projects as well :wink:

Hi there,
what about filtering and lazy loading? From the user interface perspective filtering should be able to filter all database entries as well. Is this covered by this mechanism when using the MTable?

– Mike

Hi,

Check ou
the end of the webinar.
There is an example how you can do a really efficient lazy loading (to database) with Viritin (MTable in this case). AFAIK it is the best performing solution available and also pretty easy to set up. You can also configure the batch size it uses to make backend queries with overloaded methods/constructors. The example also has filtering and if works with the lazy loading as well.

cheers,
matti

I think I need to checkout the project. I watched the webinar completly, but the “Filter” TextField above the table was not involved in the webinar.

We use for example Searchfields to limit the amout of data which might be interessting for an user. After loading the data via spring data we provide filtering on the data we “found” via search-service (overall max size is limited by service).
The filter mechanism (in this case with the FilteringTable addon) is usefull for the Users to differentiate on a more detailed level. ← We don’t want to have a searchfield for every property from our entities.

In your example there is nothing like a searchfield. So my question is, does the filter field above the table just affect the already loaded items?

For example


Database Entries:

Arnulfo Para
Bryce Magnani
Candis Crutchfield
Donny Menendez
Galen Devilbiss
Jacki Willingham
Janina Goble
Jeniffer Widell
Latisha Southwood
Lorilee Zweifel
Mackenzie Marasco
Margareta Merryman
Marion Maybee
Marlys Serra
Maura Leyba
Meg Shoults
Moriah Glassford
Nancee Tabor
Norbert Torbett
Ok Martello
Ranee Nicol
Roman Stauber
Roselee Vasquez
Sara Weitz
Sau Delamora
Stacy Petitt
Sybil Sunde
Teofila Mcwain
Thanh Phou
Torie Simonds


UI Visible Entries (nothing more is fetched lazy):

Arnulfo Para
Bryce Magnani
Candis Crutchfield
Donny Menendez
Galen Devilbiss
Jacki Willingham
Janina Goble
Jeniffer Widell
Latisha Southwood
Lorilee Zweifel


Filtering TextField with value:
Ro


User expects:

Roman Stauber
Roselee Vasquez

What will happen? Is the users expectation correct?
I hope its not to specific.

– Mike

The filtering in the example is dealt at the database level, the filter text is given to EJB method call-> then to repository-> query → database. If you only want to filter the existing result set, it is really easy and fast to do that in the JVM memory.

cheers,
matti

So user expectation is correct, but it’s filtering by query and not as i assumed filtering on loaded data.

Matti, thank you for your time.

cheers

I have question about the ManyToMany relationship… the ManyToMany which is mapp to other table, its data is not updating even though I refresh the page…

What is the cause on this situation sir ? :slight_smile:

Hi Al,

Depending how the relation is declared JPA might need you to updated from the opposite side as well, and possibly save also the other side of the entity. If you are using MultiSelectTable from Viritin, you can use the hooks presented in this test case:

https://github.com/viritin/viritin/blob/master/src/test/java/org/vaadin/viritin/it/MultiSelectTableWithCustomRelationMaintenance.java

cheers,
matti

Thank you sir Matti :slight_smile:

Vaadin legends please lend me your ear. So just started playing with Vaadin and Spring-Boot and I have attached a very very simple @ManyToMany relationship in H2 with Vaadin front end.

Unfortunatly the magic Service “load fully” hack as done in the video gives me no joy. Is it less straight forward in Spring? I think being very naive about my implimentation but unfortunately not wise enough to figure out what’s missing (exhausted google). If someone could please supply some guidance in moving over to a Lazy load stratagy I would really appreciate it.

*Note if I change the relationships to eager all is well

Thanks
29545.zip (94.5 KB)

That is a great video on webinar. A wonderful starting point to learn how to do webinar efficiently.