2017-12-19 13 views
0

내가 같이 일하고 CrudRepository '사용자 정의'찾기 방법은 다음과 같습니다봄 CrudRepository findBy 배제?

public interface ProductRepository extends CrudRepository<Product, Integer>{ 

    List<Product> findAllByVendorID(int id); 

} 

그리고 난 다음을 수행하여 전화 :

List<Product> products = productRepository.findAllByVendorID(vendor.getId()); 

을하지만 반대의 결과를 원하는, 또는 모든 경우 해당 공급 업체 ID와 관련이없는 제품은 쉽게 할 수 있습니까?

답변

1

충분합니다.

List<Product> findAllByVendorIDNot(int id); 

당신은뿐만 아니라 여러 ID를위한

List<Product> findAllByVendorIDNotIn(List<Integer> ids); 
+0

감사를-이를 확장 할 수 있습니다! 그 작품! – HoosierDude

+0

다행이었습니다. 응답을 upvote/accept하십시오. – pvpkiran