Spring Boot - Difference Between CrudRepository and JpaRepository Last Updated : 22 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework and making a production-ready application in it takes very little time. CRUD Repository There is an interface available in Spring Boot named as CrudRepository that contains methods for CRUD operations. It provides generic Crud operation on a repository. It is defined in the package org.springframework.data.repository and It extends the Spring Data Repository interface. If someone wants to use CrudRepository in the spring boot application he/she has to create an interface and extend the CrudRepository interface. Syntax: public interface CrudRepository<T, ID> extends Repository<T, ID> Where: T: Domain type that repository manages (Generally the Entity/Model class name)ID: Type of the id of the entity that repository manages (Generally the wrapper class of your @Id that is created inside the Entity/Model class) Example: public interface DepartmentRepository extends CrudRepository<Department, Long> {}JpaRepository JpaRepository is a JPA (Java Persistence API) specific extension of 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. Syntax: public interface JpaRepository<T,ID> extends PagingAndSortingRepository<T,ID>, QueryByExampleExecutor<T> Where: T: Domain type that repository manages (Generally the Entity/Model class name)ID: Type of the id of the entity that repository manages (Generally the wrapper class of your @Id that is created inside the Entity/Model class) Example: public interface DepartmentRepository extends JpaRepository<Department, Long> {}Spring Data Repository Interface Here in the following image Repository, CrudRepository and PagingAndSortingRepository belong to Spring Data Commons whereas JpaRepository belongs to Spring Data JPA. Difference Table CrudRepository JpaRepository It is a base interface and extends Repository Interface.It extends PagingAndSortingRepository that extends CrudRepository.It contains methods for CRUD operations. For example save(), saveAll(), findById(), findAll(), etc. It contains the full API of CrudRepository and PagingAndSortingRepository. For example, it contains flush(), saveAndFlush(), saveAllAndFlush(), deleteInBatch(), etc along with the methods that are available in CrudRepository.It doesn't provide methods for implementing pagination and sortingIt provides all the methods for which are useful for implementing pagination.It works as a marker interface.It extends both CrudRepository and PagingAndSortingRepository.To perform CRUD operations, define repository extending CrudRepository.To perform CRUD as well as batch operations, define repository extends JpaRepository. Syntax: public interface CrudRepository<T, ID> extends Repository<T, ID> Syntax: public interface JpaRepository<T,ID> extends PagingAndSortingRepository<T,ID>, QueryByExampleExecutor<T> Comment More infoAdvertise with us A AmiyaRanjanRout Follow Improve Article Tags : Java Difference Between Java-Spring-Boot Practice Tags : Java Similar Reads Spring Boot - DevTools Spring Boot provides DevTools, a module designed to ease your development process, it improves the experience of developing applications resulting in optimizing the developer's productivity for building exceptional software.It aims to reduce development time, by intelligently detecting code changes 5 min read Spring Boot - Dependency Management Spring Boot framework is the most popular web development framework. No doubt, it provides an abundance of essential features and a convenient way to handle those features. At the heart of Spring Boot is the 'Dependency Management' feature. Importance of Dependency ManagementCentralized Dependency M 6 min read Spring Boot - Caching Spring Boot is a project that is built on top of the Spring Framework that provides an easier and faster way to set up, configure, and run both simple and web-based applications. It is one of the popular frameworks among developers these days because of its rapid production-ready environment which e 6 min read Spring Boot - Starter Web Today most of the applications demand Model-View-Controller (MVC) architecture to meet the various needs like handling user data, making application efficient, to provide dynamic nature to applications. It was basically used for building desktop graphical user interfaces (GUIs), but now is becoming 6 min read Spring Boot - Difference Between @Service Annotation and @Repository Annotation Spring Annotations are a form of metadata that provides data about a program. Annotations are used to provide supplemental information about a program. It does not have a direct effect on the operation of the code they annotate. It does not change the action of the compiled program. @Service Annota 7 min read Unit Testing in Spring Boot Project using Mockito and Junit Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se 6 min read Spring Boot - Thymeleaf with Example Thymeleaf is a server-side Java-based template engine for both web and standalone environments, capable of processing HTML, XML, JavaScript, CSS and even plain text. It is more powerful than JPS and responsible for dynamic content rendering on UI. The engine allows a parallel work of the backend and 6 min read Spring Boot - MongoRepository with Example Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se 5 min read Spring Boot - Integrating Hibernate and JPA Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se 3 min read Spring Boot JpaRepository with Example Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se 9 min read Like