diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 39172d7f42..fe981d11f3 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -40,8 +40,6 @@ java-jpa java-jpa-2 java-jpa-3 - - java-mongodb-2 java-mongodb-3 java-mongodb-queries @@ -90,7 +88,7 @@ spring-data-jpa-repo-2 spring-data-jdbc spring-data-keyvalue - + spring-data-mongodb spring-data-mongodb-2 spring-data-mongodb-reactive spring-data-redis 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 8f86e8ce49..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,12 +51,9 @@ 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); + List findByNameOrAge(String name, Integer age); - @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 findByNameOrAgeAndActive(String name, Integer age, Boolean active); List findByNameOrderByName(String name); 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 75e0db253f..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 @@ -153,15 +153,15 @@ public class UserRepositoryIntegrationTest { } @Test - public void whenByNameOrBirthDate() { + public void whenByNameOrAge() { - assertEquals(4, userRepository.findByNameOrBirthDate(USER_NAME_ADAM, BIRTHDATE).size()); + assertEquals(3, userRepository.findByNameOrAge(USER_NAME_ADAM, 20).size()); } @Test - public void whenByNameOrBirthDateAndActive() { + public void whenByNameOrAgeAndActive() { - assertEquals(2, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size()); + assertEquals(2, userRepository.findByNameOrAgeAndActive(USER_NAME_ADAM, 20, false).size()); } @Test diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index afb5e8b9c1..87cf1acaf8 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -103,13 +103,13 @@ - 3.0.3.RELEASE - 4.3.1 + 3.4.7 + 5.0.0 1.1.3 4.1.0 - 3.2.0.RELEASE - 4.0.5 - 3.2.6 + 3.5.4 + 4.6.1 + 4.6.3 \ No newline at end of file