Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Native SQL filter in JPAContainer
In vaadin book, chapter 19.1, I found the following statement:
"The main interface in JPA is the EntityManager, which allows making different kinds of queries either with the Java Persistence Query Language (JPQL), native SQL, or the Criteria API in JPA 2.0. You can always use the interface directly as well, using Vaadin JPAContainer only for binding the data to the user interface."
I need to filter items extracted by JPAContainer with native SQL, no JPA Criteria, because I need recursive statements to express some filtering conditions.
I cannot find anywhere a sample to use native SQL with JPAContainer: is there a way to achieve this?
Thank you very much!
In most cases I don't encourage people to use JPAContainer at all, and especially in your case. It is probably much easier just to get the data you want with plain JPA API and then just list the entities your got in your UI. In Table/Selects/Grid you can use e.g. BeanItemContainer or with some more advanced methods contributed by the community.
Thank you very much for the answer!!
That's a pity, because till now I found JPAContainer very useful and ease of use.
However, it would be better if this deterrence from JPAContainer usage will be reflected in official documentation, where instead JPAContainer still has great space, with a whole chapter: it would create less disorientation in users. Instead, it would be great if official documentation outlined correct usage of other methods, whether BeanItemContainer or mode advanced ones.
Congratulations for your work, Vaadin is great.
JPAContainer is handy to get started and pretty handy to list contents of one table, but with typical Vaadin application it often becomes a burden. We are, as we speak, discussing how we should play down the role of JPAContainer in our documentation/communication. We used to sell licences for it and that way try to finance the development of the free Vaadin Framework, that it the reason why we currently have it more prominently visible than it would really deserve.
I hope we can create couple of "full stack tutorials", that contain usage of JPA within Vaadin app. First milestone was the Vaadin guide in spring.io, released yesterday. That is using the awesome Spring Data and completes the backend with Vaadin based CRUD. Check that out if you want some ideas for alternative ways to use JPA with Vaadin.