title: Spring Data Jpa Send List As a Search Parameter
body: <pre><code>public class Medicine as Entity
         ...
         ...    
      @Lob
      @ManyToMany
      @JoinTable(name = "Medicine_Ingredients")
      private Set&lt;Ingredient&gt; ingredientList = new HashSet&lt;&gt;();
  </code></pre>
  
  <p>Then I have an other List includes Ingredient objects. 
  What I want to do is in repository, I want to push List  as a parameter and get Medicines if its ingredientList contains pushed List parameter.</p>
  
  <p>I've been trying  to do this as iterating objects in for loops. But I don't think it's a clean solution. Thanks in advance!</p>
  
  <p>Update, this code block how I handle the problem for now but I don't think it's a clean solution. Will be a problem walking around all medicines coming from here:</p>
  
  <pre><code>medicineRepository.findByTradeNameStartingWithAndManufacturerStartingWith(
                      medicineSearchModel.getTradeName(),
                      medicineSearchModel.getManufacturer()
              )) 
  </code></pre>
  
  <p>---- Code Block</p>
  
  <pre><code>        List&lt;Medicine&gt; medicineList = new ArrayList&lt;&gt;();
          ArrayList&lt;String&gt; sub_ingredients = new ArrayList&lt;&gt;();
  
          for (Ingredient search_ingredient : medicineSearchModel.getIngredientList()) {
              sub_ingredients.add(search_ingredient.getId().toString());
          }
          for (Medicine medicine : medicineRepository.findByTradeNameStartingWithAndManufacturerStartingWith(
                  medicineSearchModel.getTradeName(),
                  medicineSearchModel.getManufacturer()
          )) {
              ArrayList&lt;String&gt; super_ingredients = new ArrayList&lt;&gt;();
              for (Ingredient medicine_ingredient : medicine.getIngredientList()) {
                  super_ingredients.add(medicine_ingredient.getId().toString());
              }
              if (super_ingredients.containsAll(sub_ingredients)) {
                  medicineList.add(medicine);
              }
          }
          return medicineList;
  </code></pre>