title: Spring Data JPA find by embedded object property
body: <p>I want to write a Spring Data JPA repository interface method signature that will let me find entities with a property of an embedded object in that entity. Does anyone know if this is possible, and if so how?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>@Entity
  @Table(name = "BOOK_UPDATE_QUEUE", indexes = { uniqueConstraints = @UniqueConstraint(columnNames = {
          "bookId", "region" }, name = "UK01_BOOK_UPDATE_QUEUE"))
  public class QueuedBook implements Serializable {
  
      @Embedded
      @NotNull
      private BookId bookId;
  
      ...
  
  }
  
  @Embeddable
  public class BookId implements Serializable {
  
      @NotNull
      @Size(min=1, max=40)
      private String bookId;
  
      @NotNull
      @Enumerated(EnumType.STRING)
      private Region region;
  
      ...
  
  }
  
  public interface QueuedBookRepo extends JpaRepository&lt;QueuedBook, Long&gt; {
  
      //I'd like to write a method like this, but can't figure out how to search by region,
      //when region is actually a part of the embedded BookId
      Page&lt;QueuedBook&gt; findByRegion(Region region, Pageable pageable);
  
  }
  </code></pre>
  
  <p>Can I write a query for this using Spring Data?</p>