Updated PR based on feedback

Signed-off-by: Perumal Raj A <perumalraj024@gmail.com>
This commit is contained in:
Perumal Raj A 2025-02-05 09:44:41 +00:00
parent 94d6335022
commit 98ccc1e2e4
2 changed files with 1 additions and 6 deletions

View file

@ -124,11 +124,6 @@ class OwnerController {
return "owners/ownersList"; return "owners/ownersList";
} }
// private Page<Owner> findPaginatedForOwnersLastName(int page, String lastname) {
// int pageSize = 5;
// Pageable pageable = PageRequest.of(page - 1, pageSize);
// return owners.findByLastNameStartingWith(lastname, pageable);
// }
private Page<Owner> findPaginatedForOwnersName(int page, String lastname) { private Page<Owner> findPaginatedForOwnersName(int page, String lastname) {
int pageSize = 5; int pageSize = 5;
Pageable pageable = PageRequest.of(page - 1, pageSize); Pageable pageable = PageRequest.of(page - 1, pageSize);

View file

@ -54,7 +54,7 @@ public interface OwnerRepository extends JpaRepository<Owner, Integer> {
* @return a Collection of matching {@link Owner}s (or an empty Collection if none * @return a Collection of matching {@link Owner}s (or an empty Collection if none
* found) * found)
*/ */
// Page<Owner> findByLastNameStartingWith(String lastName, Pageable pageable);
@Query("SELECT o FROM Owner o " + "WHERE LOWER(o.firstName) LIKE LOWER(CONCAT('%', :namePart, '%')) " @Query("SELECT o FROM Owner o " + "WHERE LOWER(o.firstName) LIKE LOWER(CONCAT('%', :namePart, '%')) "
+ "OR LOWER(o.lastName) LIKE LOWER(CONCAT('%', :namePart, '%'))") + "OR LOWER(o.lastName) LIKE LOWER(CONCAT('%', :namePart, '%'))")
Page<Owner> findByNameContaining(@Param("namePart") String namePart, Pageable pageable); Page<Owner> findByNameContaining(@Param("namePart") String namePart, Pageable pageable);