DAO (Data access object) / Repository Layer
- @Repository: This annotation is a stereotype that marks the repository class. It indicates that the annotated class acts as a database on which CRUD operations can take place.
- JpaRepository<Course, Long> : JpaRepository is a JPA-specific extension of the Repository. It contains the full API of CrudRepository and PagingAndSortingRepository. So it contains API for basic CRUD operations and also API for pagination and sorting. Here we enable database operations for Employees. To learn more about spring data Jpa, refer this article.
Java
import com.example.testing_001.model.Course; import org.springframework.data.jpa.repository.JpaRepository; @Repository public interface CourseRepository extends JpaRepository<Course, Long> { } |
Spring MVC CRUD with Example
CRUD stands for Create, Read/Retrieve, Update, and Delete. These are the four basic operations to create any type of project. Spring MVC is a Web MVC Framework for building web applications. It is a spring module same as Spring boot, spring-security, etc. The term MVC stands for Model-View-Controller architecture. In this article, we will be building a simple course-tracking CRUD application that will be focused on the Spring MVC module.
Contact Us