Interface ReviewRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Review,,Long> org.springframework.data.jpa.repository.JpaRepository<Review,,Long> org.springframework.data.repository.ListCrudRepository<Review,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Review,,Long> org.springframework.data.repository.PagingAndSortingRepository<Review,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Review>,org.springframework.data.repository.Repository<Review,Long>
Review entities.
Provides full CRUD operations inherited from JpaRepository
and rich query methods optimized for review management, moderation,
and display in the product catalog and customer profiles.
Reviews are user-generated content linking a Customer to a Product
with a rating (1–5) and optional text. Efficient access by customer, product,
or login is essential for:
- Displaying reviews on product pages
- Showing "My Reviews" section in customer profile
- Admin moderation tools
- Calculating average product ratings
This repository is automatically implemented by Spring at runtime — no manual implementation required.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByProduct(Product product) Deletes all reviews associated with a given product.voiddeleteByProductName(String name) Deletes all reviews for a product identified by its name.findByCustomer(Customer customer) Finds all reviews written by a specific customer.findByCustomerLogin(String login) Finds all reviews written by a customer identified by their login.findByProduct(Product product) Finds all reviews for a specific product.findByProductName(String name) Finds all reviews for a product by its name.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByCustomer
Finds all reviews written by a specific customer.Used in the customer profile ("My Reviews") and for reputation/engagement analytics.
- Parameters:
customer- the customer who wrote the reviews (must not be null)- Returns:
- a list of reviews by this customer (may be empty)
-
findByCustomerLogin
Finds all reviews written by a customer identified by their login.Useful when only the login is known (e.g., from authentication context) and full
Customerentity is not loaded.- Parameters:
login- the customer's login/username- Returns:
- a list of reviews written by the customer with this login
-
findByProduct
Finds all reviews for a specific product.Primary method for displaying reviews on product detail pages and calculating average rating and review count.
- Parameters:
product- the product being reviewed (must not be null)- Returns:
- a list of all reviews for this product (ordered by date descending by default)
-
findByProductName
-
deleteByProduct
Deletes all reviews associated with a given product.Used when a product is permanently removed from the catalog. Typically called within a service that handles cascading deletion.
Warning: This is a destructive operation affecting user-generated content. Consider soft-delete, archiving, or anonymization instead.
- Parameters:
product- the product whose reviews should be deleted
-
deleteByProductName
Deletes all reviews for a product identified by its name.Convenience method for batch operations when only the product name is available.
- Parameters:
name- the name of the product whose reviews should be deleted
-