This project is a simple CRUD (Create, Read, Update, Delete) application developed using Java and Spring Boot. The application utilizes Maven as its build tool and MySQL as the database. The project adheres to a typical Spring Boot structure and employs the DAO (Data Access Object) pattern for handling database operations.
- Main entry point of the application.
- Contains the main method to initiate the Spring Boot application.
- Defines a CommandLineRunner bean for executing code at application startup.
- Interface specifying operations on Student entities.
- Operations include creating a new student, finding a student by ID, retrieving all students, finding students by last name, updating a student's details, and deleting a student by ID or all students.
- Implementation of the StudentDAO interface.
- Utilizes the EntityManager to interact with the database.
- Each method is annotated with @Transactional to ensure operations are performed within a transaction.
- Entity class representing a student in the application.
- Fields include the student's ID, first name, last name, and email.
The project architecture is straightforward. The CruddemoApplication class uses the StudentDAO to perform operations on Student entities. The actual implementation of StudentDAO interacts with the database to persist Student entities. The code adheres to clean code principles and emphasizes separation of concerns, ensuring each class has a specific responsibility and interacts with others through well-defined interfaces. This promotes code readability, testability, and maintainability.
The application.properties file contains database connection and logging configurations, specifying the MySQL database URL, username, and password. Additionally, it configures Hibernate to display SQL statements and binding parameters in the logs.
- Spring Boot: Provides features such as dependency injection, transaction management, and database integration.
- Jakarta Persistence API (JPA): Simplifies object-relational mapping for database operations.
The project is built with Maven, handling dependencies and the build process. The pom.xml file contains Maven configuration, including dependencies and build plugins.