Spring data rest is Null 이나 is Not null
Spring data rest 에서 query parameter 로 is null 이나 is not null 을 하고싶었는데,
"http://localhost:1000/organizations?parent=IsNull" 처럼 호출해서
"select * from organization where parent is null" 와 같은 쿼리를 호출하고 싶어서 찾아보니
"Perhaps in the future, we'll be able to specify how to interpret null parameters using the @NullMeans annotation. Notice that it's a proposed feature at this time and is still under consideration."
미래에 ..... 사용할수 있을거라한다.
(참고 꼼수 : http://localhost:1000/organizations?parent=-999 처럼 없는id값을 넣으니까 JPA 에서 ID로 조회를 해보고 없으니까 IS NULL 로 조회를 했다). Not NUll 도 할수있는 꼼수라도 있으면 댓글 부탁드립니다.
지금은 아래처럼.... 하라고 포스팅에서 말해주고있다....
@Query("SELECT c FROM Customer c WHERE (:name is null or c.name = :name) and (:email is null or c.email = :email)")
List<Customer> findCustomerByNameAndEmail(@Param("name") String name, @Param("email") String email);
www.baeldung.com/spring-data-jpa-null-parameters
Spring Data JPA and Null Parameters | Baeldung
Learn different ways to use null parameters with Spring Data JPA queries, including how to make query parameters optional.
www.baeldung.com