This exercise is a Spring Boot tutorial focused on setting up the Data Access Layer for a Java application.
Specifically, the tutorial guides you through the following core development tasks:
Creating a Model Package: Organizing the project by creating a package named com.csc3402.lab.staff.model.
Defining an Entity: Creating a Staff Java class and using Jakarta Persistence (JPA) annotations like @Entity, @Id, and @Column to map the class to a database table.
Standard Class Methods: Using IntelliJ IDEA's automated tools to generate essential Java boilerplate code, including Getters and Setters, a no-argument constructor, and a toString() method.
Creating a Repository Package: Setting up a package for data access interfaces.
Implementing Spring Data JPA: Creating a StaffRepository interface that extends JpaRepository<Staff, Integer>. This allows the application to perform database operations (CRUD) without writing complex SQL.
Automatic Table Creation: Demonstrating how Spring Boot and Hibernate automatically create the STAFF table in an H2 in-memory database upon starting the application.
Data Seeding: Creating a data.sql file in the resources folder to automatically populate the database with initial staff records (e.g., James Dean, Steve Jobs) when the application runs.
Verification: Using the H2 Console via a web browser (http://localhost:8080/h2-console) to verify that the table was created and the data was successfully inserted.