JAVA-20167 Upgrade spring-data hibernate with external libraries specific modules to JDK 11 (#14022)

Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
timis1 2023-05-19 09:48:45 +03:00 committed by GitHub
parent 539bf3438d
commit d9182f160c
3 changed files with 9 additions and 4 deletions

View File

@ -87,7 +87,7 @@
<module>spring-data-jpa-query</module>
<module>spring-data-jpa-query-2</module>
<module>spring-data-jpa-query-3</module>
<!-- <module>spring-data-jpa-repo</module> FAILED -->
<module>spring-data-jpa-repo</module>
<module>spring-data-jpa-repo-2</module>
<module>spring-data-jdbc</module>
<module>spring-data-keyvalue</module>

View File

@ -2,6 +2,8 @@ package com.baeldung.derivedquery.repository;
import com.baeldung.derivedquery.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.ZonedDateTime;
import java.util.Collection;
@ -49,9 +51,12 @@ public interface UserRepository extends JpaRepository<User, Integer> {
List<User> findByAgeIn(Collection<Integer> ages);
List<User> findByNameOrBirthDate(String name, ZonedDateTime birthDate);
@Query(value = "select * from users where (name = :nameParam OR birth_date <> :birthDateParam)", nativeQuery = true)
List<User> findByNameOrBirthDate(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam);
List<User> findByNameOrBirthDateAndActive(String name, ZonedDateTime birthDate, Boolean active);
@Query(value = "select * from users where (name = :nameParam OR birth_date <> :birthDateParam) and active = :activeParam", nativeQuery = true)
List<User> findByNameOrBirthDateAndActive(@Param(value = "nameParam") String nameParam, @Param(value = "birthDateParam") ZonedDateTime birthDateParam,
@Param(value = "activeParam") Boolean activeParam);
List<User> findByNameOrderByName(String name);

View File

@ -161,7 +161,7 @@ public class UserRepositoryIntegrationTest {
@Test
public void whenByNameOrBirthDateAndActive() {
assertEquals(3, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size());
assertEquals(2, userRepository.findByNameOrBirthDateAndActive(USER_NAME_ADAM, BIRTHDATE, false).size());
}
@Test