From c76a1e8c45ec56aba2c16b6240e418988b1ead08 Mon Sep 17 00:00:00 2001 From: timis1 Date: Sat, 17 Jun 2023 00:41:28 +0300 Subject: [PATCH] JAVA-20167 Remove methods that are not presented in articles --- .../derivedquery/repository/UserRepository.java | 7 ------- .../UserRepositoryIntegrationTest.java | 16 ++-------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/persistence-modules/spring-data-jpa-repo/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java b/persistence-modules/spring-data-jpa-repo/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java index 4b2d6c11af..7d4a208d26 100644 --- a/persistence-modules/spring-data-jpa-repo/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java +++ b/persistence-modules/spring-data-jpa-repo/src/main/java/com/baeldung/derivedquery/repository/UserRepository.java @@ -51,13 +51,6 @@ public interface UserRepository extends JpaRepository { List findByAgeIn(Collection ages); - @Query(value = "select * from users where (name = :nameParam OR birth_date <> :birthDateParam)", nativeQuery = true) - List findByNameOrBirthDate(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam); - - @Query(value = "select * from users where (name = :nameParam OR birth_date <> :birthDateParam) and active = :activeParam", nativeQuery = true) - List findByNameOrBirthDateAndActive(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam, - @Param(value = "activeParam") Boolean activeParam); - List findByNameOrAge(String name, Integer age); List findByNameOrAgeAndActive(String name, Integer age, Boolean active); diff --git a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java index 719f56e3cd..cf479780a1 100644 --- a/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-repo/src/test/java/com/baeldung/derivedquery/repository/UserRepositoryIntegrationTest.java @@ -152,28 +152,16 @@ public class UserRepositoryIntegrationTest { assertEquals(3, userRepository.findByAgeIn(ages).size()); } - @Test - public void whenByNameOrBirthDate() { - - assertEquals(4, userRepository.findByNameOrBirthDate(USER_NAME_ADAM, BIRTHDATE).size()); - } - - @Test - public void whenByNameOrBirthDateAndActive() { - - assertEquals(2, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size()); - } - @Test public void whenByNameOrAge() { - assertEquals(2, userRepository.findByNameOrAge(USER_NAME_ADAM, 20).size()); + assertEquals(3, userRepository.findByNameOrAge(USER_NAME_ADAM, 20).size()); } @Test public void whenByNameOrAgeAndActive() { - assertEquals(3, userRepository.findByNameOrAgeAndActive(USER_NAME_ADAM, 20, false).size()); + assertEquals(2, userRepository.findByNameOrAgeAndActive(USER_NAME_ADAM, 20, false).size()); } @Test