JAVA-20167 Adding additional example for Spring data derived query
This commit is contained in:
parent
caf72a58b2
commit
64dd4ce8d3
|
@ -58,6 +58,10 @@ public interface UserRepository extends JpaRepository<User, Integer> {
|
||||||
List<User> findByNameOrBirthDateAndActive(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam,
|
List<User> findByNameOrBirthDateAndActive(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam,
|
||||||
@Param(value = "activeParam") Boolean activeParam);
|
@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> findByNameOrderByName(String name);
|
||||||
|
|
||||||
List<User> findByNameOrderByNameDesc(String name);
|
List<User> findByNameOrderByNameDesc(String name);
|
||||||
|
|
|
@ -164,6 +164,18 @@ public class UserRepositoryIntegrationTest {
|
||||||
assertEquals(2, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size());
|
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
|
@Test
|
||||||
public void whenByNameOrderByName() {
|
public void whenByNameOrderByName() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue