Interface ProductRepo

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Product,Long>, org.springframework.data.jpa.repository.JpaRepository<Product,Long>, org.springframework.data.repository.ListCrudRepository<Product,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<Product,Long>, org.springframework.data.repository.PagingAndSortingRepository<Product,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Product>, org.springframework.data.repository.Repository<Product,Long>

public interface ProductRepo extends org.springframework.data.jpa.repository.JpaRepository<Product,Long>
Spring Data repository for Product entities.

Inherits CRUD, pagination, and sorting from JpaRepository and adds a simple case-insensitive name search.

Examples


 // Page through all products, newest first
 Page<Product> page = repo.findAll(PageRequest.of(0, 20, Sort.by(DESC, "id")));

 // Search by name, case-insensitive
 Page<Product> mugs = repo.findByNameContainingIgnoreCase("mug", PageRequest.of(0, 10));
 

Performance tips:

  • Consider an index on lower(name) for large catalogs to speed up case-insensitive matching.
  • Always pass a Pageable to avoid loading large result sets into memory.

Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.data.domain.Page<Product>
    findByNameContainingIgnoreCase(String name, org.springframework.data.domain.Pageable pageable)
    Finds products whose name contains the given keyword, ignoring case sensitivity; paged.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findByNameContainingIgnoreCase

      org.springframework.data.domain.Page<Product> findByNameContainingIgnoreCase(String name, org.springframework.data.domain.Pageable pageable)
      Finds products whose name contains the given keyword, ignoring case sensitivity; paged.
      Parameters:
      name - the substring to search for within product names (case-insensitive)
      pageable - the pagination and sorting information; never null
      Returns:
      a page of products matching the search criteria; never null