What is the difference between CrudRepository, JpaRepository, and PagingAndSortingRepository? CrudRepository, JpaRepository और PagingAndSortingRepository में क्या अंतर है?
CrudRepository is the base interface providing basic CRUD operations: save(), findById(), findAll(), delete(), and count(). PagingAndSortingRepository extends it and adds findAll(Pageable) and findAll(Sort) for pagination and sorting.
JpaRepository extends both and adds JPA-specific features such as batch operations (saveAll(), deleteAllInBatch()), flushing (flush()), and returning results as a List instead of an Iterable. For most Spring Boot + JPA projects, JpaRepository is the practical default since it includes everything the other two provide.
public interface UserRepository extends JpaRepository<User, Long> {
Page<User> findAll(Pageable pageable);
}CrudRepository बेस इंटरफेस है जो बुनियादी CRUD ऑपरेशन्स प्रदान करता है: save(), findById(), findAll(), delete(), और count()। PagingAndSortingRepository इसे एक्सटेंड करता है और पेजिनेशन व सॉर्टिंग के लिए findAll(Pageable) और findAll(Sort) जोड़ता है।
JpaRepository दोनों को एक्सटेंड करता है और बैच ऑपरेशन्स (saveAll()), फ्लशिंग (flush()) जैसी JPA-विशिष्ट सुविधाएँ जोड़ता है, और Iterable के बजाय List के रूप में परिणाम रिटर्न करता है। अधिकतर स्प्रिंग बूट + JPA प्रोजेक्ट्स के लिए JpaRepository व्यावहारिक डिफ़ॉल्ट है।
public interface UserRepository extends JpaRepository<User, Long> {
Page<User> findAll(Pageable pageable);
}Was this answer clear?