Spring Data JPA provides a way to execute database manipulation commands on the application startup. As the schema will be generated in the database from the JPA entity configuration and ddl-auto property value, we have to take care to insert the account records in the accounts table only. The following are the steps to accomplish this:
- Add the following property to the application.properties file:
- Create a data.sql file with INSERT queries in the src/main/resources folder of the project:
INSERT INTO accounts (ACCT_NAME) VALUES ('Savings'), ('Current'), ('Fixed Deposit'), ('Recurring Deposit'), ('Loan');
That's it! When we start the application, Spring will ...