title: Spring Data JPA : query to find objects by list?
body: <p>I have 2 classes: book and category which have a OneToMany relationship.
  I want to pass a list of string containing categories. The result should return all books which match any of the category in the list. for example if a book has 5 category and it matches with only 1 on the list, it should still be returned.</p>
  <p>This is what I came up with but its not working.</p>
  <pre><code>//Models: 
  
  @Entity
  @Table(name = &quot;Book&quot;)
  @Data
  public class Book {
      @Id
      private String id;
      @OneToMany
      private List&lt;Category&gt; category;
  }
  
  @Entity
  @Table(name=&quot;Category&quot;)
  @Data
  public class Category {
      @Id
      private int id;    
      private String category;
  }
  
  // 
  
  @Repository
  public interface BookDao extends JpaRepository&lt;Book, Integer&gt; {
      
      @Query(&quot;SELECT b FROM Book b join b.category c where c.category in :category&quot;)
      Page&lt;Book&gt; getBooksByCat(Pageable pageable, @Param(&quot;category&quot;) List&lt;String&gt; category);
  
  }
  
  </code></pre>