JAVA-20167 Adding additional example for Spring data derived query

This commit is contained in:
timis1 2023-06-15 20:59:56 +03:00 committed by n
parent caf72a58b2
commit 64dd4ce8d3
2 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,10 @@ public interface UserRepository extends JpaRepository<User, Integer> {
List<User> findByNameOrBirthDateAndActive(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam,
@Param(value = "activeParam") Boolean activeParam);
List<User> findByNameOrAge(String name, Integer age);
List<User> findByNameOrAgeAndActive(String name, Integer age, Boolean active);
List<User> findByNameOrderByName(String name);
List<User> findByNameOrderByNameDesc(String name);

View File

@ -164,6 +164,18 @@ public class UserRepositoryIntegrationTest {
assertEquals(2, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size());
}
@Test
public void whenByNameOrAge() {
assertEquals(2, userRepository.findByNameOrAge(USER_NAME_ADAM, 20).size());
}
@Test
public void whenByNameOrAgeAndActive() {
assertEquals(3, userRepository.findByNameOrAgeAndActive(USER_NAME_ADAM, 20, false).size());
}
@Test
public void whenByNameOrderByName() {