Use PostgreSQL data in Vaadin 10+

Hello. I’m trying to get data from some tables and views in a PostgreSQL 10.5 database into a web UI that a store manager could use.
I generated a Maven project with Java and Spring Boot 2.1.2 using Spring Initializr and imported it into IntelliJ IDEA. It has the following properties:

Group: com.dbproject
Artifact: storeui
Dependencies: Spring Integration, Vaadin, MyBatis, PostgreSQL

I’ve watched about a dozen videos and read just as many tutorials, but i haven’t found any recent ones that specifically use PostgreSQL for their backend database. So far I have Java classes for all of the tables in the database but I don’t know what to do with them to get them into a Grid or anything.

I’ve attached the schema for my database. Thank you in advance for any help.
17466795.txt (6.54 KB)

There is no specific implementation for PostgreSQL (or any other specific database). You have to implement a (lazy loading) DataProvider as middleman between your application and the (PostgreSQL) database, see https://vaadin.com/docs/flow/binding-data/tutorial-flow-data-provider.html

You can also take a look here: http://www.vaadinonkotlin.eu/databases-v10.html (uses kotlin, but to get the idea).

If you are using Spring Boot and most likely like to use Spring Data, I recommend to check full stack app starter [vaadin.com/start]
(https://vaadin.com/start/latest/full-stack-spring) It is Spring Boot application, the default config is with H2 and there is info how to change setup to Mysql, using PostgreSQL is done in similar fashion.

Alright, I’ve been reading those since yesterday but I’m not sure how much I’ll be able to convert it to Java. I’m a beginner in Java, at best. Before I continue i just wanted to make sure I’m using the version of Vaadin I should be, I thought I saw something about 12.3.3 coming out. Do I need MyBatis for this? I was watching a video a few days ago that looked like the DataProvider was MyBatis, but then I realized it was for Vaadin 8 when the @SpringUI Annotation and a couple others couldn’t find resources for symbols. Also, I need to readd the Java classes I made for my PostgreSQL tables after IntelliJ removed all my Vaadin resources. Any advice on naming the member variables?

<properties>
		<java.version>1.8</java.version>
		<vaadin.version>12.0.3</vaadin.version>
</properties>

I just wanted to let you know that even after two weeks of researching every day just to figure out how to get the rows in my database tables to show in a grid, I’m still no closer to making that a reality. The generic videos and tutorials you make using an in-memory database showing how to fill a grid with 4 or 5 rows are useless to people using a real backend such as PostgreSQL, or MySQL, etc. If I were skilled enough to use that to make what I need, I wouldn’t need the video to begin with and i wouldn’t have asked how to do it on here. “There is no specific implementation for PostgreSQL (or any other specific database)” doesn’t help WHATSOEVER because I’ve never connected database tables to a UI before. How hard would it be to write one tutorial for each major database to show how to connect a table to a Java class and then use it with Components? I can’t use the full stack Spring starter because I don’t have Pro, partly because my professor tried to contact you about getting Education licenses for us and never got a reply.

Hi Kevin, I understand your frustration. I think most of Vaadin’s documentation and tutorials assume the audience has previous experience with Java, and so some explanations are frequently left out. I’m planning to rewrite the “Vaadin + some_database” articles at some point and would try my best to keep a broader audience in mind.

However, I’d like to understand you better so I can write better content in the future as well. Would you be up for a video call so I can show you how to implement a CRUD with Vaadin 10+ and PostgreSQL/MySQL?

Thank you, I would definitely be up for that. Did you have a specific time in mind for when you would like to do that?

Kevin Palembas:
Thank you, I would definitely be up for that. Did you have a specific time in mind for when you would like to do that?

Great. Please drop me a message and we’ll schedule a suitable time: alejandro@vaadin.com

Here’s a running example: https://github.com/alejandro-du/postgres-vaadin-10-mybatis-demo

Thank you for the time you spent to explain things to me Alejandro. I hope the demo helps many other people, as well.

Kevin Palembas:
Thank you for the time you spent to explain things to me Alejandro. I hope the demo helps many other people, as well.

Thanks for your time too. Happy coding!