Skip to content

Commit

Permalink
Fixed the function names relating to Id, to correctly call the JPA cr…
Browse files Browse the repository at this point in the history
…iteria API
  • Loading branch information
nhkhai committed Mar 21, 2024
1 parent 8390fed commit 9af5dc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// We can also create custom queries using the JPA criteria API by simply creating a method with a certain naming convention specified by the query creation mechanism.
public interface CustomerRepository extends JpaRepository<Customer, Long> {
// Custom query to find all customers with a certain ID.
List<Customer> findByID(long id);
List<Customer> findById(long id);

// Custom query to find all customers with a certain first name.
List<Customer> findByFirstName(String firstName);
Expand All @@ -20,7 +20,7 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
List<Customer> findByLastName(String lastName);

// Custom query to find all customers with a certain first name and last name.
List<Customer> findByFirstNameAndLastNameAsc(String firstName, String lastName);
List<Customer> findByFirstNameAndLastName(String firstName, String lastName);

// Custom query to find all customers with a certain country.
List<Customer> findByCountry(String country);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// We can also create custom queries using the JPA criteria API by simply creating a method with a certain naming convention specified by the query creation mechanism.
public interface ProductRepository extends JpaRepository<Product, Long> {
// Custom query to find all products with a certain ID.
List<Product> findByID(long id);
List<Product> findById(long id);

// Custom query to find all products with a certain category.
List<Product> findByCategory(String category);
Expand All @@ -26,5 +26,5 @@ public interface ProductRepository extends JpaRepository<Product, Long> {
List<Product> findByPrice(double price);

// Custom query to find all products with a certain stock quantity.
List<Product> findByQuantity(int stockQuantity);
List<Product> findByStockQuantity(int stockQuantity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// We can also create custom queries using the JPA criteria API by simply creating a method with a certain naming convention specified by the query creation mechanism.
public interface ReviewRepository extends JpaRepository<Review, Long> {
// Custom query to find all reviews with a certain ID.
List<Review> findByID(long id);
List<Review> findById(long id);

// Custom query to find all reviews with a certain category.
List<Review> findByCategory(String category);
Expand All @@ -23,11 +23,11 @@ public interface ReviewRepository extends JpaRepository<Review, Long> {
List<Review> findByRating(int rating);

// Custom query to find all reviews with a certain customer ID.
List<Review> findByCustomerID(long customerId);
List<Review> findByCustomerId(long customerId);

// Custom query to find all reviews with a certain product ID.
List<Review> findByProductID(long productId);
List<Review> findByProductId(long productId);

// Custom query to find all reviews with a certain customer ID and product ID.
List<Review> findByCustomerIDAndProductID(long customerId, long productId);
List<Review> findByCustomerIdAndProductId(long customerId, long productId);
}

0 comments on commit 9af5dc2

Please sign in to comment.