How does Vaadin know to execute commands SQL commands in data.sql? [Starter Project Tutorial]

I’m new to Vaadin, please bear with me…

Basically I’ve just finished this part of the tutorial here: and I’m not sure where in the codebase is the app being told to run the SQL commands in src/main/resources/data.sql. I’m curious because I’m wondering if I can use multiple .sql files to store SQL commands.

Also, at this stage of the tutorial, what database system are we using? PostgreSQL or is it something else? I want to be able to look into the tables into this database - where are the SQL commands that are creating them on startup?

Thanks in advance, and sorry if this question is not in the right place!

There is no need for you to run any SQL commands yourself. Spring Boot will load that data.sql file automatically on startup into the in-memory H2 database

I see, and if I want to make a Vaadin project, I just have to download the starter and everything is ready for me? (I’m using intellij)
Could I also try and make a Vaadin project from scratch so I have more control over which tables are in my database?

The data.sql file is specific to this tutorial so you have some data to work with as you are learning Vaadin. It’s not something you would likely have in a real app.

Vaadin does not impose limitations on how you handle your database. You can use JPA, jOOQ, JDBC, or any other way you’re comfortable with

and I can assume that the JPA/JDBC/etc are all things that you can get through spring boot?

Correct. The most common way to do it is through Spring Data, which is what the tutorial does

the start website

The tutorial uses an in-memory H2 database for development and a postgresql database for production

okay, that makes a lot more sense. The next thing I’m thinking about is: if I want to make a new table into this H2 database, do I add a class into the entity package and put an @Entity tag above the class?

Correct. And then you can use a Spring Data repository to perform database operations

righto that is absolutely brilliant. Thanks for now Marcus, I really appreciate the tutorial video as well

Great to hear! Have fun hacking and feel free to post any further questions here on Discord :slightly_smiling_face: