Before running the project, go to the MySQL Workbench app, the cha6_dbtest table, and cha6_dbtest_schema. There you will notice that there will be no table named user_jpa, which was mentioned in the UserModel class as a table name.
Here is the screenshot of the schema where we have no table:
Let's run the application, check the database again, and refresh the schema. Notice that now there is a table as we mentioned in the @Table annotation of the UserModel. This has all the columns of that object, including—id, name, email, and contact_number.
Here is the screenshot of the updated database:
The testing system is the same as the JDBC. Please check this yourself, and if you are confused, then go to the Testing the Output of JDBC project.
Here is the REST API URL of this project:
- GET http://localhost:8080/users: To get a list of all users
- GET http://localhost:8080/user/1: To get a specific user details
- POST http://localhost:8080/user/new: To insert a new user
- PUT http://localhost:8080/user/1: To update a specific user details
- DELETE http://localhost:8080/user/2: To delete a specific user details