title: spring data jpa for multiple joined table
body: <p>I have two tables: ProductUsage and Learner. ProductUsage have field Learner, Learner has fields id and guid. now I need to create a query to pull out all productUsage whose learner guid is in specified user ids:</p>
  
  <p>SQL:</p>
  
  <pre><code>select * from product_usage 
  inner join learner
  on product_usage.learner_id = learner.id
  where 
  learner.guid in ("1234", "2345")
  </code></pre>
  
  <p>domain class:</p>
  
  <pre><code>@Data
  @NoArgsConstructor
  @Entity
  @Table(name = "core_product_usage_increments")
  public class ProductUsage {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Integer id;
  
      @ManyToOne
      @JoinColumn(name = "learner_id", nullable = false)
      private Learner learner;
  
      @ManyToOne
      @JoinColumn(name = "learning_language_id", nullable = false)
      private Language language;
  }
  
  @Data
  @NoArgsConstructor
  @Entity
  @Table(name = "learners")
  public class Learner {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Integer id;
  
      @Column(name = "user_guid", nullable = false, unique = true)
      private String guid;
  
      @Column(name = "first_name")
      private String firstName;
  
      @Column(name = "last_name")
      private String lastName;
  }
  </code></pre>
  
  <p>and repository class:</p>
  
  <pre><code>@Repository
  public interface ProductUsageRepository extends CrudRepository&lt;ProductUsage, Integer&gt; {
      @Query("SELECT p FROM ProductUsage p WHERE p.learnerGuid = :learnerGuid")
      List&lt;ProductUsage&gt; findByLearnerGuid(String learnerGuid);
  }
  </code></pre>
  
  <p>client class that call the repository </p>
  
  <pre><code>@Component
  public class MyClient {
      @Autowired
      private ProductUsageRepository repository;
  
      public MyClient(ProductUsageRepository repository) {
          this.repository = repository;
      }
  
      public List&lt;ProductUsage&gt; getProductUageByLeanrerGuid(String learnerGuid) {
          return repository.findByLearnerGuid(learnerGuid);
      }
  }
  </code></pre>
  
  <p>and my test:</p>
  
  <pre><code>@Test
      public void testClient() throws Exception {
          MyClient client = new MyClient(repository);
          List&lt;ProductUsage&gt; results = client.getProductUageByLeanrerGuid("1234");
          assertNotNull(result);
      }
  </code></pre>
  
  <p>and it failed:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: learnerGuid of: com.acme.domain.spectrum.ProductUsage [SELECT p FROM com.acme.domain.spectrum.ProductUsage p WHERE p.learnerGuid = :learnerGuid]
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1364)
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
      at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:294)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
  </code></pre>
  
  <p>it cannot recognize the 'learnerGuid' field in ProductUsage, but that's actually defined in Learner class. how can I perform the query that join multiple tables? </p>