Spring Data JPA : JpaRepository vs CRUDRepository vs PagingAndSortingRepository

preview_player
Показать описание
#JpaRepository #CRUDRepository #PagingAndSortingRepository
► Difference between CrudRepository and JpaRepository and PagingAndSortingRepository interfaces in Spring Data JPA
► SUBSCRIBE & LIKE!!
► Download the sample java microservice application :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
► Here is our amazing playlist for Core Java, Spring MVC/Boot, Git and Micro service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Watch my "Most Watched Videos"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Important Notes Related to Spring Data JPA Repository
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
► JpaRepository extends PagingAndSortingRepository which in turn extends CrudRepository.
Their main functions are:
• CrudRepository mainly provides CRUD functions.
• PagingAndSortingRepository provides methods to do pagination and sorting records.
• JpaRepository provides some JPA-related methods such as flushing the persistence context and deleting records in a batch.
Because of the inheritance mentioned above, JpaRepository will have all the functions of CrudRepository and PagingAndSortingRepository. So if you don't need the repository to have the functions provided by JpaRepository and PagingAndSortingRepository , use CrudRepository.
====================================
► CrudRepository - extends Repository
====================================
save(…) – save an Iterable of entities. Here, we can pass multiple objects to save them in a batch
saveAll(…) – Save all the entities
findById (…) – get a single entity based on passed primary key value
findAll() – get an Iterable of all available entities in database
findAllById(…) - get an Iterable of all available entities in database by matching criteria
count() – return the count of total entities in a table
delete(…) – delete an entity based on the passed object
deleteById(…) – delete an entity based on unique id value
deleteAll(…) – delete all entity from the table
existsById(…) – verify if an entity exists based on the passed primary key value
================================================
► PagingAndSortingRepository - extedns CrudRepository
================================================
In addition, CRUDRepository method below two additions are there
Iterable(T) findAll(Sort sort);
Page(T) findAll(Pageable pageable);
This interface provides a method findAll(Pageable pageable), which is the key to implementing Pagination
Example: I want to sort the record by name ascending order and each page should contain 10 records.
Sort sort = new Sort(new Sort.Order(Direction.ASC, "name"));
Pageable pageable = new PageRequest(0, 10, sort);
================================================
► JpaRepository - extends PagingAndSortingRepository
================================================
In addition, CRUDRepository method + PagingAndSortingRepository method + below methods
findOne (…) – get a single entity based on passed primary key value
flush() – flush all pending task to the database
saveAndFlush(…) – save the entity and flush changes immediately
deleteInBatch(…) – delete an Iterable of entities. Here, we can pass multiple objects to delete them in a batch
deleteAllInBatch() – delete all entities.

Regards,
Debu Paul
Рекомендации по теме
Комментарии
Автор

The way you explained the GrandFather, Parent and Child is amazing and crystal clear. Thank you for making such an amazing video

naveenlalam
Автор

Today I watched ur all the video related to the data jpa and Thnks great effort

pratapjavasingh
Автор

Thank you sir for this video and explained very nice way

Atul_Shegokar
Автор

wow. u r a good teacher sir. thank u so much

alfredochola
Автор

i want to run Hibernate JPA with CURD project.. in eclipse that's why I need Hibernate jar files .. but I am using Linux OS i ..I want jar files supportable with eclipse & Ubuntu os

mohangabhale
Автор

Where can I get Hibernate jar files supportable for Ubuntu operating system

mohangabhale
Автор

Thanks For This Explain Can We Create Abstract Repository And Service For JPA Repository If It's Possible How Can We Used In Abstract Services

mekha
join shbcf.ru